Skip to content

Conversation

@baywet
Copy link
Member

@baywet baywet commented Dec 11, 2025

fixes #2638, reflection of #2639

var initialPosition = stream.Position;
var firstByte = (char)stream.ReadByte();

// Skip whitespace if present and read the next non-whitespace byte

Choose a reason for hiding this comment

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

It feels like this comment is misleading. It mentions that it will read the next non-whitespace byte, but actually it seems like it reads the next byte unconditionally, regardless of what character it is. Considering whitespace is insignificant in JSON, it seems fair to assume multiple leading spaces are present. Changing the if to a while seems like it could do the trick?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, it was a bit outside of the initial scope but I made the change.

@sonarqubecloud
Copy link

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

Successfully merging this pull request may close these issues.

OpenApiDocument.LoadAsync with non-seekable JSON stream and no format fails to read document

3 participants