-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Group schema components by content-type #3168
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
Comments
Is your desire to group the |
Because they are distinct and I don't want to pollute the name of the schema For example, in my So we have 2 distinct schemas:
application/json_user:
type: object
properties:
id:
type: string
role:
type: string
enum: [ admin, regular ]
application/custom+json_user:
type: object
properties:
id:
type: string
role:
type: object
properties:
_t:
type: string
enum: [ enum ]
_v:
type: string
enum: [ admin, regular ] |
You could use subschemas inside /components/schemas, via $defs: components:
schemas:
user:
$defs:
application/json:
..
application/custom:
.. And then reference them as |
This indeed partially works, but
As we can see in the image
I would like to have an explicit example of this in OAI spec, then swagger-ui and other tools will be able to implement proper support. |
@karenetheridge it would be great if you could PR a new example to the |
@MikeRalphson I can do this PR? |
Note that |
Something like this components:
schemas:
Error:
$defs:
application/json:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
text/plain:
type: string Can be added to petstore example |
@MikeRalphson // @karenetheridge is there anything i can do to help? |
@souenzzo anyone can submit a PR! For a PR on the examples, you need a slight change as the first thing under
So you would use It's probably worth making a separate example rather than changing Petstore as my impression is that Petstore is the basic starting point. But that's just my impression, not any sort of official guidance. Beyond that, you'll need swagger-ui to support OAS 3.1 which looks like it might happen in version 5.0. Theres nothing that the OAS spec can do about that. |
I'm working on an API that has many content-type, and they use references to schema
The references to the
user
entity, for example, aren't the same on each content-type.I'm currently handling that by adding a content-type prefix on each schema:
I'd like to use something like
The text was updated successfully, but these errors were encountered: