-
Notifications
You must be signed in to change notification settings - Fork 187
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
Multiple responses for one response code #577
Comments
Hello, I'd like to also know if this is possible or planned? Thank you |
@jimpanse42 You example: paths:
/path:
get:
responses:
'200':
description: Success
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ResponseOne'
- $ref: '#/components/schemas/ResponseTwo' Does not specify multiple responses for the the same response code, but multiple response body schemas. If both I gave it a go with the following: openapi: 3.0.2
info:
title: Some Service
description: Some description
version: 1.0.0
paths:
/users:
get:
summary: Gets a list of users.
responses:
'401':
$ref: '#/components/responses/Unauthorized'
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/responses/Unauthorized'
# Descriptions of common components
components:
responses:
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
# Schema for error response body
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message And you will notice the However if what you're trying to achieve is associating the response of multiple media types with schemas this can be done with something like:
and to associate a single media type with multiple schemas you can point to an |
Hey,
for OpenAPI 3.x specs there is the possibility to declare multiple responses for one specific response code, as per example here:
Would it be possible to extend the controller response definition to be able to pass multiple response schemas aswell?
For cases where an additional query parameter changes the returned object or adds fields to it.
E.g.
Thanks in advance
The text was updated successfully, but these errors were encountered: