-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat(openapi): improvements to circular ref detection, validation errors #1189
Conversation
@@ -93,8 +93,13 @@ additionalProperties: | |||
· #/components/schemas/ParameterizedHeader/properties/parameters/additionalProperties | |||
|
|||
circularRefs: | |||
· #/components/schemas/BodyPart/properties/parent |
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.
These circular refs weren't being picked up before but @apidevtools/json-schema-ref-parser
is better at detecting them now with an onCircular
hook I submitted to them. APIDevTools/json-schema-ref-parser#366
@@ -172,10 +172,14 @@ ADDITIONAL PROPERTY must NOT have additional properties | |||
29 | "summary": "Finds Pets by status",] | |||
`; | |||
|
|||
exports[`rdme openapi validate > error handling > should throw an error if an invalid OpenAPI 3.0 definition is supplied 1`] = `[MissingPointerError: Token "Error" does not exist.]`; | |||
exports[`rdme openapi validate > error handling > should throw an error if an invalid OpenAPI 3.0 definition is supplied 1`] = ` | |||
[ValidationError: API definition schema validation failed. |
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.
Slightly nicer error message here with this header being shown instead of dumping the user out with "Token "Error" does not exist."
@@ -47,7 +47,7 @@ | |||
"@oclif/plugin-help": "^6.2.15", | |||
"@oclif/plugin-not-found": "^3.2.28", | |||
"@oclif/plugin-warn-if-update-available": "^3.1.19", | |||
"@readme/better-ajv-errors": "^2.0.0", | |||
"@readme/better-ajv-errors": "^2.3.2", |
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.
v2.3.2 was already installed but I just bumped it in the package file.
sorry i think #1188 might have caused merge conflicts 🫠 |
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.
just updated the PR title so it's a bit more customer-facing. LGTM!
one quick non-blocking q — should we add a test that illustrates this? 👇🏽
The error leveling work is not being used within
rdme
but for things like specification validation that our parser doesrdme
will now be able to surface more than one of these errors at a time. 🎉
Feel like that's already well tested across |
# [10.2.0-next.5](v10.2.0-next.4...v10.2.0-next.5) (2025-03-05) ### Features * **openapi:** improvements to circular ref detection, validation errors ([#1189](#1189)) ([57b732f](57b732f)) [skip ci]
🎉 This PR is included in version 10.2.0-next.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
🧰 Changes
Over the past couple weeks I've been rewriting our OpenAPI parser,
@readme/openapi-parser
, to support a new error leveling system -- you can read up on details on this in readmeio/oas#943. This PR pulls in the fruits of my labor there and acrossoas
andoas-normalize
.oas-normalize
to pull in our new parser engine and error handling. The error leveling work is not being used withinrdme
but for things like specification validation that our parser doesrdme
will now be able to surface more than one of these errors at a time. 🎉oas
and@readme/oas-examples
to pull in the removal of Node 18 support.All told this overhaul is mostly a drop-in replacement with the exception that instead of
SyntaxError
andMissingPointerError
exceptions being thrown from the parser for some invalid API definition cases it will now always be aValidationError.