redoc icon indicating copy to clipboard operation
redoc copied to clipboard

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

Open KomalYadav10796 opened this issue 2 years ago • 7 comments
trafficstars

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?

KomalYadav10796 avatar Mar 01 '23 11:03 KomalYadav10796

Can you share the corresponding OAS to reproduce?

adamaltman avatar Mar 05 '23 14:03 adamaltman

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 avatar Mar 13 '23 07:03 mastery-komal-yadav

Hello @adamaltman / @AlexVarchuk

Any updates on the above issues?

mastery-komal-yadav avatar Mar 16 '23 12:03 mastery-komal-yadav

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

mastery-komal-yadav avatar May 16 '23 12:05 mastery-komal-yadav

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

NGanip avatar Jul 04 '24 05:07 NGanip

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 avatar Jul 11 '24 01:07 NGanip

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

NGanip avatar Jul 11 '24 05:07 NGanip