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

Rendering response examples still buggy #206

Closed
maxarndt opened this issue May 7, 2020 · 5 comments
Closed

Rendering response examples still buggy #206

maxarndt opened this issue May 7, 2020 · 5 comments

Comments

@maxarndt
Copy link

maxarndt commented May 7, 2020

It looks like you've lost sight of the other issue (#198). Just as a friendly reminder.

Thanks for your quick response!

Unfortunately, the issue is not finally fixed.

If you have a string property with format date-time in your arrays object, the example value does not render correctly. It shows up as empty object.

But this worked with earlier versions of RapiDoc.

components:
  schemas:
    Events:
      type: array
      items:
        type: object
        properties:
          fileName:
            type: string
            example: file.txt
          someDate:
            type: string
            format: date-time
      example:
        - fileName: fileA.txt
          someDate: 2017-07-21T17:32:28Z
        - fileName: fileB.txt
          someDate: 2020-04-20T18:11:14Z

This leads to:

[
  {
    fileName: "fileA.txt",
    someDate: { },
  },
  {
    fileName: "fileB.txt",
    someDate: { },
  }
],

You can find the updated API spec yaml in my updated repo as well: https://github.com/maxarndt/rapidoc-bug-minimal-demo

I did not test which data types and formats are affected as well of this issue.

Originally posted by @maxarndt in #198 (comment)

@mrin9
Copy link
Collaborator

mrin9 commented May 7, 2020

I did loose sight of this issue, please feel free to reopen issue's that aren't properly addressed. that way it will get our attention.

I will investigate on this

@maxarndt
Copy link
Author

maxarndt commented May 7, 2020

I would have liked to do that, but unfortunately I don't have access to reopen an issue that was closed in this repository.

Thanks for looking into it!

@mrin9 mrin9 closed this as completed in 34edf6e May 8, 2020
@mrin9
Copy link
Collaborator

mrin9 commented May 8, 2020

Well, to render the examples, we are using a home grown JSON tree component. It is also used in other parts of the app, therefore I addressed it in a way that fits well

As a consequence, there is a little fix that needs to be done in the spec too.

Since someDate in your example is of type 'string' it should be provided in double/single quotes (for yaml based spec)

it needs to be provided like below (notice the double quotes around the date value)

example:
  - fileName: "fileA.txt"
    someDate: "2017-07-21T17:32:28Z"
  - fileName: "fileB.txt"
    someDate: "2020-04-20T18:11:14Z"

this will instruct the JSON tree component that it should treat someDate as a String else it will try to convert that into Date object

PS: let me know that works (if you are unable to reopen this issue, open a new one and link this one) Do you happen to know why you arn't able to re-open issues ? does it gray out ? or shows any reason ? from our end, It is non-intentional, but I would like to fix it if others too are having this problem

@maxarndt
Copy link
Author

maxarndt commented May 11, 2020

That works for me! Thanks @mrin9.

I think you should note it somewhere that double quotes are necessary to get the expected output because if you don't use them it does not completely fail but you get an output like

{
  "someDate": "Thu Jul 23 2020 16:27:08 GMT+0200 (Mitteleuropäische Sommerzeit)"
}

Regarding the re-open issue: There is no reopen button at all. There is only a "Comment" button. This seems to be an known issue: isaacs/github#583

@meyer-r
Copy link

meyer-r commented Nov 16, 2021

@mrin9,
in my view the proposed quotation of the date-time value is just a workaround. RapiDoc should never auto-interpret strings in date/date-time format as date.
OpenAPI yaml definition doesn't need quotes on date/date-time values.
As we are using a code-first approach to generate the OpenAPI yaml (using swagger-core framework), we have no change to insert quotes to workaround the issue.

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