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

Regression: OAS2 response examples are not displayed #5458

Closed
hkosova opened this issue Jul 12, 2019 · 4 comments · Fixed by #5464 or #5465
Closed

Regression: OAS2 response examples are not displayed #5458

hkosova opened this issue Jul 12, 2019 · 4 comments · Fixed by #5464 or #5465

Comments

@hkosova
Copy link
Contributor

hkosova commented Jul 12, 2019

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: any
  • Method of installation: https://editor.swagger.io
  • Swagger-UI version: 3.23.0
  • Swagger/OpenAPI version: OpenAPI 2.0

Content & configuration

Example Swagger/OpenAPI definition:

swagger: "2.0"
info:
  title: test
  version: 1.0.0
paths:
  /foo1:
    get:
      summary: Response without a schema
      produces:
        - application/json
      responses:
        200:
          description: Successful response
          examples:
            application/json:
              foo: custom value
  /foo2:
    get:
      summary: Response with schema
      produces:
        - application/json
      responses:
        200:
          description: Successful response
          schema:
            $ref: '#/definitions/Foo'
          examples:
            application/json:
              foo: custom value

definitions:
  Foo:
    type: object
    properties:
      foo:
        type: string
        example: bar

Describe the bug you're encountering

/pull/5427 seems to have introduced an issue where OAS2 response examples are not displayed if the response does not have a schema defined. Previous versions of Swagger UI rendered the response examples in this case.

Expected behavior

Both /foo1 and /foo2 display the following response example, as it was in Swagger UI v. 3.22.3:

{
  "foo": "custom value"
}

Response example in Swagger UI

Actual behavior

/foo1 does not display any example.
/foo2 displays schema-based example instead of the custom example from examples.

Wrong response examples

@hkosova hkosova changed the title Regression: OAS2 response examples are not displayed if the response does not have schema Regression: OAS2 response examples are not displayed Jul 12, 2019
@shockey
Copy link
Contributor

shockey commented Jul 13, 2019

(P1 in order to push this above #5453 and #5455)

@shockey
Copy link
Contributor

shockey commented Jul 13, 2019

thanks as always @hkosova!

@shockey
Copy link
Contributor

shockey commented Jul 13, 2019

wait a second

My implementation missed the mark, it's generating custom value instead of the entire object.

Reopening.

@shockey
Copy link
Contributor

shockey commented Jul 13, 2019

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants