Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing arguments to referenced objects #672

Closed
tenodi opened this issue Apr 26, 2016 · 3 comments
Closed

Support passing arguments to referenced objects #672

tenodi opened this issue Apr 26, 2016 · 3 comments

Comments

@tenodi
Copy link

tenodi commented Apr 26, 2016

I want my API documentation to be concise. Therefor, I want to define anything repeating in the top level members in Swagger object. Since I'm using JSON API , I have some boilerplate, as data followed by the actual representation in the resource. Usual definition of 201 response, looks like:

 responses:
   Created:
     description: new resource
     headers:
       Location:
         type: string
         format: uri
     schema:
       type: object
       required:
       - data
       properties:
       - data:
           $ref: '#/definitions/resourceDefinition'

I will use that Created definition in my Operations object as:

 responses:
   '201':
     $ref: '#/definitions/Created'

And that's great. But, how can I pass an argument in the form of resourceDefinition and any other parts that I will need? Every API endpoint has its own resource definitions (and other specifics) and my API documentation (in comments in above the code) would be too large to write it constantly. I failed to find a way to pass argument to referenced object.

Is there anything I could do?

This is what I would like to be able to do:

Docs above my API endpoint:

 responses:
   '201':
     $ref: '#/definitions/Created'
     args:
     - resourceDefinition: '#/definitions/Foo'

Docs in top level responses property:

 responses:
   Created:
     description: new resource
     headers:
       Location:
         type: string
         format: uri
     schema:
       type: object
       required:
       - data
       properties:
       - data:
           $ref: '#args/resourceDefinition'
@ePaul
Copy link
Contributor

ePaul commented Apr 26, 2016

So basically you want parameterized data types?

I don't think this is something which the OpenAPI spec wants to do, though maybe some kind of tooling can pre-process your input into the official form.

Though maybe this can be incorporated in some way in #555 (or meta-issue #586).

@ralfhandl
Copy link
Contributor

This sounds similar to the parameterized templates/patterns for Path Item objects that I proposed in #588.

@webron
Copy link
Member

webron commented May 19, 2016

Closing this as it is indeed duplicated over tickets mentioned in #555 and should be covered there (best to keep discussions in one place). Personally, I see the value in parameterized data types, which is a solution to the problem.

@tenodi - keep in mind that your proposal will not work unless we decide to go with a 'fix' for #556.

@webron webron closed this as completed May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants