How to use 'projections' in SwaggerHub API definition properly?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to use 'projections' in SwaggerHub API definition properly?
I have the same resource and the same verb (GET), but would like to get different attribute sets as a response. How do I have to use 'projections' properly to be able to enter various GETs for the same resource?
Or is 'projection' the wrong way? Or is there another better way?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, great question. Take a look at this example:
https://swaggerhub.com/api/swagger-tutorials/modeling-samples/1.0.0
Which shows how you would handle different but related input/output models with Swagger.
Tony Tam
SmartBear VP of Swagger Products
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, thanks for your answer.
But I guess I formulated my question not the way I should.
What I try to get is the possibilty, to offer the API requester the chance, to choose from different sets of response attributes of the same resource.
Means, resource /user has 4 response attributes:
- name
- street
- town
- country
As a requester, I should be able to choose only name and street as a response (xs-response), or name, street, town and country (xl-response).
Is there a way to offer this possibility?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately no, the specification for the definition does now allow you to do that. You are welcome to file enhancements against the specification here:
https://github.com/OAI/OpenAPI-Specification/issues
Tony Tam
SmartBear VP of Swagger Products
