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

swagger not showing multiple examples in request body #4017

Closed
john1452 opened this issue Dec 11, 2017 · 2 comments
Closed

swagger not showing multiple examples in request body #4017

john1452 opened this issue Dec 11, 2017 · 2 comments

Comments

@john1452
Copy link

john1452 commented Dec 11, 2017

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? SwaggerHub
Which Swagger-UI version? SwaggerHub
How did you install Swagger-UI? no using the one from SwaggerHub
Which browser & version? chrome latest
Which operating system? windows 10

Demonstration API definition

As stated in documentation here https://swagger.io/docs/specification/adding-examples/
In OpenApi 3.0 swagger supports multiple examples in requestbody. However, on swagger hub this is not the case. I have replicated the example provided in the documentation. It appears that examples in the request body are not taken into consideration when rendering the UI

I have created an example api using the yaml code from the documentation above.
Please see: https://app.swaggerhub.com/apis/SoftInc/kkk/1.0.0

YAML

paths:
  /users:
    post:
      summary: Adds a new user
      requestBody:
        content:
          application/json:     
            schema:             
              $ref: '#/components/schemas/User'  
            examples:    
              Jessica:  
                value:
                  id: 10
                  name: Jessica Smith
              Ron:      
                value:
                  id: 11
                  name: Ron Stewart
      responses:
        '200':
          description: OK
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

Current Behavior

The code above includes two examples of the user Jessica and Ron
When the above request is rendered on the UI it's displayed as below.

{
  "id": 0,
  "name": "string"
}

Expected Behavior

Based on the open 3.0 documentation link provided. The expected results should be (multiple examples):

{
  "id": 10,
  "name": "Jessica Smith"
},
{
  "id": 11,
  "name": "Ron Stewart"
}

Context

I want to use multiple examples in a response array to show all the possible errors that can be returned from the end point.

@hkosova
Copy link
Contributor

hkosova commented Dec 11, 2017

This is being tracked #3437.

@shockey
Copy link
Contributor

shockey commented Dec 11, 2017

Closing as duplicate. Thanks @john1452!

@shockey shockey closed this as completed Dec 11, 2017
@lock lock bot locked and limited conversation to collaborators Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants