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

example in requestBody.content.<media-type> can't override which defined in schema. #4225

Closed
liu946 opened this issue Feb 15, 2018 · 3 comments

Comments

@liu946
Copy link

liu946 commented Feb 15, 2018

Q A
Bug or feature request? bug
Which Swagger/OpenAPI version? 3.0.0
Which Swagger-UI version?
How did you install Swagger-UI? use the online version on app.swaggerhub.com
Which browser & version? chrome
Which operating system? osx

Demonstration API definition

I test the online hub https://app.swaggerhub.com use the yaml code following, but I get the unexpected generation at right side of the page (like the following screenshot). I think it will generated like the document (https://swagger.io/docs/specification/describing-request-body/) as the example in requestBody.content. will override which defined in schema but it seems like the example I defined makes no sense.
2018-02-15 11 42 24

https://app.swaggerhub.com/apis/liu946/ssp/1.0.0

paths:
  /users:
    post:
      summary: Adds a new user
      requestBody:
        content:
          application/json:    # Media type
            schema:            # Request body contents
              $ref: '#/components/schemas/User'   # Reference to an object
            example:           # Child of media type because we use $ref above
              # Properties of a referenced object
              id: 10
              name: Jessica Smith
      responses:
        '200':
          description: OK
components:
  schemas:
    # basic data structure
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

Expected Behavior

generate example object like { id: 10, name: Jessica Smith}

Current Behavior

generate a {id: 0, name: "string"} object

Waiting for your help, please.

@hkosova
Copy link
Contributor

hkosova commented Feb 16, 2018

Support for media type examples is being tracked in #3437 and #4092.

@kzhou57
Copy link

kzhou57 commented Jun 22, 2018

+1 for this feature.

@webron
Copy link
Contributor

webron commented Jul 12, 2018

Closing this one in favor of #3437.

@webron webron closed this as completed Jul 12, 2018
@lock lock bot locked and limited conversation to collaborators Jul 12, 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

4 participants