Skip to content

feat: Re-design of the Preprocessor to Reach and Strip all Examples in the Schema #1051

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 12 commits into
base: master
Choose a base branch
from

Conversation

max-at-silverflow
Copy link

This MR is a spin-off of #1040, and aims to fix #931. It introduces the following changes:

  • Add a test to verify Exclude OpenAPI Examples from Response Validation #931 has been fixed.
  • Expose an additional type from the OpenAPIV3 namespace (and fixes prettier in the types file).
  • Redesign the preprocessor to scan the entire API schema for examples, using the same pattern as the original implementation.

The changes are quite extensive. The new preprocessor serves as a drop-in replacement, but changes how the schema is traversed. Most importantly, it traverses much more of the schema than the old design, which is required to reach all examples. In turn, it only requires a single pass to perform pre-processing and stripping all examples, in contrast to the simpler solution provided in #1040.

If you have any questions about it, let me know!

Closes #931.
Replaces #1040.

@max-at-silverflow
Copy link
Author

I also just tested this with a larger project of my own, and with the relatively complex schema there I did not find any issues. Doesn't mean that all edge cases have been covered, but should be a good indication.

@cdimascio
Copy link
Owner

@max-at-silverflow this is a large change. What is your confidence, particularly regarding the series work?

@max-at-silverflow
Copy link
Author

max-at-silverflow commented Mar 17, 2025

Yeah, it is quite a chunk... So, from my perspective, I can say the following:

  • It does work with all the current tests. Depending on how confident you are into those, that should be a good indication.
  • I have tested it with one of my projects, which is a proper real-world application with schemas that are way more complicated than anything in the tests.

Neither of this is conclusive, obviously. And considering the user base of this project, I would rather not promise that it is perfect and bug-free. I have spent significant effort to make it as stable as possible, but I have done this change on my own, so it was only a single pair of eyes.

If I had to make a decision here, I would probably opt for a beta release, if you have that option. That would give the opportunity to gather some more feedback in the wild.

And if anyone else wants to give their feedback, that is obviously also more than welcome!

Let me know what you think!

Edit: It also has to be said that I am not an expert with OpenAPI or validation. I have tried to stick to the original behavior as much as possible, and only expand it over the entire schema.

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.

Exclude OpenAPI Examples from Response Validation
2 participants