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

Schemas that make much use of $ref can cause Newtonsoft to if schema validation fails #326

Open
idg10 opened this issue Mar 3, 2023 · 1 comment

Comments

@idg10
Copy link
Contributor

idg10 commented Mar 3, 2023

If Menes detects that input fails schema validation, it attempts to produce a 400 response that describes the problem, and which includes a copy of the schema that has been violated.

At some point (we think somewhere mid 2022) the Microsoft OpenAPI libraries started including reference details where $ref has been used, that end up including a pointer back to the whole OpenAPI doc. This causes Menes to crash because we end up with loops when trying to serialize the schema. But in any case, we shouldn't even be trying to copy the entire open API doc.

We need to work out how to stop it doing this. That might entail using the OpenApi library's built in functionality for serializing schemas. Or it might involve customizing how we serialize the thing.

First, we need to make the problem repro in the PetStore project, and then fix that.

@idg10
Copy link
Contributor Author

idg10 commented Mar 3, 2023

Looks like this behaviour came in with an update to the Microsoft OpenAPI libraries, and then was fixed in a later release, so it no longer repros. However, we're no longer confidence that the code serializing the schema in the error response is doing things the best way. Look into whether we should use a different way to serialize the schema into the response.

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

1 participant