-
Notifications
You must be signed in to change notification settings - Fork 677
feat(openapi-parser): validator overhaul #7171
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
base: main
Are you sure you want to change the base?
Conversation
|
|
Hello Scalar! Big fan of the tooling you all are building here. I'm looking to use some of the tools here on our API Specifications at SailPoint and I want to refine the error handling a bit and hopefully get some better output in certain situations, so I took a look at the underlying validation logic and I think I was able to make some good changes here. Would anyone mind reviewing this PR? If you are happy with these changes I have some additional changes/improvements in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing to @geoffgscott @amritk @DemonHa to review :) but looks cool!
|
@marclave I believe @hanspagel is back! This is parser stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE
Actually, I‘d love to see a version that doesn’t use ajv somehow, and a functional approach. This was more or less copied from somewhere and has a bunch of flaws.
That said, your PR is a huge improvement over the status quo. 🙏
packages/openapi-parser/tests/openapi3-examples/3.0/fail/invalidSchemaName.test.ts
Outdated
Show resolved
Hide resolved
| "requestBody1": { | ||
| "content": { | ||
| "application/json": { | ||
| "description": "Pet object that needs to be added to the store", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we remove those comments? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Descriptions are invalid at these places in the document
packages/openapi-parser/tests/openapi3-examples/3.0/fail/invalidPattern.test.ts
Outdated
Show resolved
Hide resolved
packages/openapi-parser/tests/openapi3-examples/3.0/fail/hasFlowNotFlows.test.ts
Outdated
Show resolved
Hide resolved
| errors: transformErrors(entrypoint, validateSchema.errors), | ||
| errors: transformErrors(specification, validateSchema.errors), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call it document?
I know, people refer to it as the "specification", but the specification is the actual standard, not the document (or definition).
|
Great feedback! I'll make some changes when I log on for the day |
…idSchemaName.test.ts Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
…idPattern.test.ts Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
…owNotFlows.test.ts Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
Problem
Currently, …
Solution
With this PR …
Checklist
I've gone through the following:
pnpm changeset).Note
Upgrades AJV and schemas to improve OpenAPI validation (incl. refs in paths) and delivers clearer, deduplicated errors with expanded tests.
src/lib/Validator/Validator.ts):Ajv; enablediscriminatorandallErrorsoptions.specificationtotransformErrors; refine error handling.schemas/v2.0): allowpathsentries to beoneOfpathItemorjsonReference.schemas/v3.0): introducePathItemOrReferenceand use it inPaths; adddiscriminatortoSecuritySchemeoneOf; clean upPathItemfields.schemas/v3.1): usepath-item-or-referenceforpaths.schemas/v3.2): usepath-item-or-referenceacrosspaths,webhooks, and componentpathItems; add conditionalpath-item-or-referenceand related structural updates.types: extendErrorObjectwith optionalpath.betterAjvErrors: addoneOf/if/additionalProperties/unevaluatedPropertieshandling; smarter redundancy filtering.transform-errors: guard invalid specs, try/catch fallback to raw AJV errors, formatadditionalPropertiesmessages, deduplicate by message+path.tests/openapi3-examples/3.0/fail/*):openapi-vue).Written by Cursor Bugbot for commit bb56d7e. This will update automatically on new commits. Configure here.