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

Response examples are not appearing #205

Closed
alexandrehtrb opened this issue Aug 11, 2022 · 11 comments
Closed

Response examples are not appearing #205

alexandrehtrb opened this issue Aug 11, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@alexandrehtrb
Copy link

Describe the bug

Response examples are not appearing for a request; they do appear when I preview my OpenApi in Swagger Editor.
(I presume this feature is available, I searched and found the PR #176 ).

Expected behavior

A response example like the one below should show up:

image

Current behavior

My response example does not show:

image

Steps to reproduce

My API config in docusaurus.config.js plugin section:

api_shoppinglist: { 
  specPath: "openapis/swagger_shoppinglist.yaml",
  outputDir: "docs/api_shoppinglist",
  sidebarOptions: {
    groupPathsBy: "tag",
    categoryLinkSource: "tag",
    sidebarCollapsible: true,
    sidebarCollapsed: false
  }
}

My OpenAPI file is available at: https://pastebin.com/n0n4dTu7

Your Environment

  • Docusaurus version used: v2.0.1
  • Docusaurus OpenAPI Docs version used: v1.1.4
  • Environment name and version: Node.js v16.16
  • Operating System and version (desktop or mobile): Windows 10 x64
@alexandrehtrb alexandrehtrb added the bug Something isn't working label Aug 11, 2022
@sserrata
Copy link
Member

Thanks for reporting @alexandrehtrb. There are a number of bug fixes coming in v1.1.5 that should address your issue. Can you test using canary release 0.0.0-422 and let me know if it works?

@sserrata
Copy link
Member

I was able to reproduce the issue you are seeing. I'll need to check with @blindaa121 to see what the issue might be.

@sserrata
Copy link
Member

Hmmm, I think I figured it out...it appears we were only checking for examples and not example, which is also supported.

Screen.Recording.2022-08-11.at.2.50.00.PM.mov

@sserrata
Copy link
Member

sserrata commented Aug 11, 2022

Please install 1.1.5 and let me know if it resolves your issue. Thanks!

@alexandrehtrb
Copy link
Author

I tried the new version and the result was the same as in your video.
Is it possible to have the layout like in the video of the PR #176 ? I liked that design.

I also started to have an error in another OpenApi documentation, here is the stack trace:

[ERROR] TypeError: Cannot read properties of null (reading 'value')
    at C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\createStatusCodes.js:66:72
    at Array.map (<anonymous>)
    at createResponseExamples (C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\createStatusCodes.js:57:45)
    at C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\createStatusCodes.js:129:37
    at guard (C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\utils.js:21:26)
    at C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\createStatusCodes.js:97:47
    at Array.map (<anonymous>)
    at createStatusCodes (C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\createStatusCodes.js:83:33)
    at createApiPageMD (C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\markdown\index.js:44:51)
    at C:\PROJETOS\TesteDocusaurus\my-website\node_modules\docusaurus-plugin-openapi-docs\lib\index.js:168:54

(I cannot share this OpenApi right now, I will see if I can remove the sensitive parts)

@sserrata
Copy link
Member

Can you share only your response example(s)?

@alexandrehtrb
Copy link
Author

Can you share only your response example(s)?

I believe it was this response:

responses:
  '201':
    description: A solicitação com o seu status.
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/AfvafafafResult'
        example:
          id: 45df45a7-a87f-46f1-a632-17f414e051f0
          tipo: ZgfaysfJsfkafa
          status: Sfhfahajsfha
          ff1: 0
          ff2: 0
          konuln: null
          fififi:
            nomeIfjasghfkajhsfa: NAME LASTNAME
            vadasa:
              nome: NAME LASTNAME
              documento: 11.111.111/0001-00
            dedede:
              nome: NAME LASTNAME
              documento: 11.111.111/0001-00
            permiteAkfoafkoaf: false
            valorMin: 180.5
            valorMax: 180.5
            dataMaxUtc: '0001-01-01T00:00:00+00:00'
            moeda: BRL
            valor: 180.5
            dataWfuifaUtc: '2021-04-24T16:55:27.193Z'
            dataOfoaifaUtc: '2021-04-23T16:55:27.193Z'
            mofafmoasfa: '11111111111111111111111111111111111111111111111'
          erro: null
          datauiDwUtc: '2021-04-23T16:55:27.196Z'

@sserrata
Copy link
Member

Thanks! I will work on reproducing. By the way...can you share specifically what about the #176 video you would like?

@alexandrehtrb
Copy link
Author

I liked it more, for being a single example:
image

In the Shopping List example, each field in the response example YAML became a different "response example" in the documentation page:

image

(Id, Title and Items are JSON fields of the original response example)

@sserrata
Copy link
Member

sserrata commented Aug 11, 2022

I think I solved it.

Screen.Recording.2022-08-11.at.5.14.18.PM.mov

@alexandrehtrb
Copy link
Author

I tried the latest version here and it is working nicely! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants