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

Issue with nested object examples. #1365

Closed
Doyle-kun opened this issue Oct 4, 2017 · 6 comments
Closed

Issue with nested object examples. #1365

Doyle-kun opened this issue Oct 4, 2017 · 6 comments

Comments

@Doyle-kun
Copy link

Doyle-kun commented Oct 4, 2017

Hi I have a problem with adding examples to nested objects. They are not rendering, no mater which method I'm using.
My structure:

   AuthenticationToken:
      type: object
      properties:
        accessToken:
          $ref: "#/components/schemas/JWTToken"
        refreshToken:
          $ref: "#/components/schemas/JWTToken"
JWTToken:
   type: object
   properties:
    token:
     type: string

My example:

    RefreshJWTToken:
      value:
        token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE1MDY5Mjg4ODQsImV4cCI6MTUzODQ2NDg4NCwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSJ9.LmTf-0LqFGG6ZOACtA5JOEYh0Et9eNaXsyP2QCYchRQ
        name: JWT Refresh Token example
      summary: Sample refresh Token

My REST response:

responses:
        '200':
          description: "Access token refreshed"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AuthenticationToken"
              example:
                accessToken: null
                refreshToken: 
                   $ref: "#/components/examples/RefreshJWTToken"

What exactly I'm trying to get is renderable example for both access and refresh token.
It should look like this:

{
  "accessToken": {
    "token": "extremely.long.string.containing.access.token"
  },
  "refreshToken": {
    "token": "little.shorter.string.containing.refresh.token"
  }
}

How can I properly add examples to accessToken and refreshToken objects?

Thanks for help,
Gregory

@Doyle-kun Doyle-kun changed the title [OpenApi.next] Issue with nested object examples. Issue with nested object examples. Oct 4, 2017
@MikeRalphson
Copy link
Member

Is $ref: "#components/examples/RefreshJWTToken" just a typo above, or are you missing the / from #/ in the reference?

@Doyle-kun
Copy link
Author

Doyle-kun commented Oct 4, 2017

Actually just a typo, I've spent a while to get this done and had to made mistake... But without typo it's still not working. :/ Corrected.

@shockey
Copy link

shockey commented Oct 4, 2017

They are not rendering, no mater which method I'm using.

You say it isn't rendering - are you using a tool to display your API definition?

@Doyle-kun
Copy link
Author

Yes, I have docker image of Swagger Editor 3.1.8.

@shockey
Copy link

shockey commented Oct 5, 2017

@Doyle-kun, OAS 3.0 example/examplesis not implemented in Swagger-UI (which is what you see in the right-hand side of Swagger-Editor), see swagger-api/swagger-ui#3641.

Also, please note that this repository is for the OpenAPI specification itself - the Swagger-UI and Swagger-Editor tools have their own issue trackers 😄

@webron
Copy link
Member

webron commented Oct 5, 2017

Closing as it's a tooling-specific question. Please file a ticket with the respective project if needed.

@webron webron closed this as completed Oct 5, 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

4 participants