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

Do not resolve $ref in OAS 2.0 response examples #4765

Closed
hkosova opened this issue Jul 26, 2018 · 0 comments · Fixed by swagger-api/swagger-js#1810
Closed

Do not resolve $ref in OAS 2.0 response examples #4765

hkosova opened this issue Jul 26, 2018 · 0 comments · Fixed by swagger-api/swagger-js#1810

Comments

@hkosova
Copy link
Contributor

hkosova commented Jul 26, 2018

Q&A (please complete the following information)

  • OS: Windows 7
  • Browser: Chrome latest
  • Method of installation: http://editor.swagger.io
  • Swagger-UI version: 3.17.5
  • Swagger/OpenAPI version: 2.0

This issue was originally reported on Stack Overflow: https://stackoverflow.com/questions/51095684/ref-in-response-example

A similar issue for OAS 3.0 was reported in #4564 and fixed in swagger-api/swagger-js#1349.

Describe the bug you're encountering

From what I understand, OAS 2.0 response examples (responses.<code>.examples.<media-type>) are inline examples and do not support $ref. But Swagger UI tries to resolve properties named $ref in these examples.

Swagger/OpenAPI definition

swagger: '2.0'
info:
  title: test
  version: 0.0.0
paths:
  /:
    get:
      responses:
        200:
          description: OK
          examples:
            application/json:
              status: ok
              $ref: '#/definitions/Foo'

Actual behavior

Response example is displayed as

{
  "status": "ok"
}

Expected behavior

Response example is displayed as

{
  "status": "ok",
  "$ref": "#/definitions/Foo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants