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

Json example showing null in an array of string instead of properties with string values. #2273

Open
KomalYadav10796 opened this issue Mar 1, 2023 · 7 comments

Comments

@KomalYadav10796
Copy link

Describe the bug
We're experiencing issues with Redocly.
Json example showing null in an array of string instead of properties with string values.
We're using the same code and swagger schema everywhere, but it's not working in some places while getting json example from [FromBody] parameter of API.
As shown in the screenshots.

Expected behavior
image

Screenshots
swaggerschema issue

Additional context
We have used Swashbuckle.AspNetCore.ReDoc 6.4.0.

Could you please help with this?

@adamaltman
Copy link
Member

Can you share the corresponding OAS to reproduce?

@mastery-komal-yadav
Copy link

Hello @adamaltman / @AlexVarchuk

Please find below screenshots of OAS to reproduce this issue.

Screenshots:

  1. We have configured the below settings in the startup.cs file.

image

  1. swagger.json response

image

@mastery-komal-yadav
Copy link

Hello @adamaltman / @AlexVarchuk

Any updates on the above issues?

@mastery-komal-yadav
Copy link

Hello @adamaltman / @AlexVarchuk / @joshprice Is there an update on the above issue?

@NGanip
Copy link

NGanip commented Jul 4, 2024

I'm currently facing the same issue, anyone have any idea what might the cause of the bug?

@NGanip
Copy link

NGanip commented Jul 11, 2024

After debugging on my own, I found the problem in src/services/models/MediaType.ts on line 79:

image

Before this line, I already checked that this.schema and parser.spec have the correct data. However, after the creation of default, it doesn't have the correct value.

The value is processed by Sampler, which is imported from openapi-sampler.

Here’s the breakdown of what I observed:

  1. Before Line 79:
  • this.schema has the correct data.
  • parser.spec has the correct data.
  1. After Line 79:
  • default does not have the correct value.

Screenshot 2024-07-11 092308

the last object of the value shouldn't be undefined, it should contains another object

It seems the issue lies within how Sampler.sample processes the schema and spec. Any insights or suggestions on how to resolve this would be appreciated.

@NGanip
Copy link

NGanip commented Jul 11, 2024

you just need to set the value of redoc configuration generatedPayloadSamplesMaxDepth into something higher than 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants