Skip to content

Fix OpenApiJsonSchema array parsing #62051

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

BrennanConroy
Copy link
Member

Fixes #62023

We weren't reading before calling the recursive function which meant we'd never advance the Utf8JsonReader and always be in the state reader.TokenType == JsonTokenType.StartArray

@BrennanConroy BrennanConroy requested a review from a team as a code owner May 21, 2025 18:27
@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label May 21, 2025
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Comment inline about possibly adding coverage for custom converts that emit objects instead of arrays.

None = 1
}

public class EnumArrayTypeConverter : JsonConverter<EnumArrayType>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the object case already reads before recursing correctly but we should we add a type with a Write that emits an object to validate that?

@@ -140,6 +140,7 @@ internal sealed partial class OpenApiJsonSchema
{
type = JsonSchemaType.Array;
var array = new JsonArray();
reader.Read();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reader.Read();
// Read to process JsonTokenType.StartArray before advancing
reader.Read();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi
Projects
None yet
2 participants