Skip to content

$ref in response example is not correctly processed #1882

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

Closed
paulprogrammer opened this issue Jan 18, 2016 · 7 comments
Closed

$ref in response example is not correctly processed #1882

paulprogrammer opened this issue Jan 18, 2016 · 7 comments

Comments

@paulprogrammer
Copy link

I have a responses block that uses $ref to include an example:

      responses:
        200:
          description: Success
          schema:
            $ref: 'profile-models.yaml#/ProfileSearchResponse'
          examples:
            application/json:
              $ref: 'ProfileExample.yaml#/ProfileSearchResponseExample'

The $ref for the schema is correctly processed and rendered in the swagger-ui, but the $ref for the example shows the following in the swagger-ui display:

image

I would expect that the content of the $ref would appear as if it were inline.

@fehguy
Copy link
Contributor

fehguy commented Jan 18, 2016

This use case should be covered already. Can you verify the versions that you're using? And assuming you have a file called profile-models.yaml at the same location as your swagger.json?

@webron
Copy link
Contributor

webron commented Jan 18, 2016

Actually, I wouldn't expect this to be supported. The Example Object has a wildcard value and the results would be displayed as-is. While the spec is not explicit either way, personally that's how I'd interpret it (it is also not included in our reusability guide). Since it potentially makes sense, I'd suggest opening a ticket on the spec so the support for it would be more explicit in the next version.

@paulprogrammer
Copy link
Author

@fehguy I downloaded from the master branch just a few days ago. The first reference (to profile-models.yaml in schema) works fine -- it's the second (to ProfileExample.yaml) in examples which does not.

@webron That kinda makes sense, but it conflicts with the definition of $ref inherited from the json-schema spec which is supposed to behave the same way everywhere.

I need to break up the spec, because it's otherwise becoming an unruly document without any way to divide the work amongst my team. Examples are a great thing to externalize, because they can then stand alone, be referenced, updated, or included verbatim in sample implementations.

@fehguy
Copy link
Contributor

fehguy commented Jan 18, 2016

@webron is right. Examples are taken as literal objects or strings and regardless of rendering they will not be processed for resolution.

@webron
Copy link
Contributor

webron commented Jan 18, 2016

@paulprogrammer - your expectations are understandable, which is why I encourage you to open a ticket on it on the spec itself.

@paulprogrammer
Copy link
Author

I opened an issue in the specification #544 to address this.

@webron
Copy link
Contributor

webron commented Jan 18, 2016

Already labeled ;)

@webron webron closed this as completed Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants