Repository navigation
Parse only OpenAPI documents and resolve only internal refs - #1291
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAPI import handed whatever it decoded to swagger-parser with its default options. Pasted text that is not a document (one user pasted curl commands) became a plain string, which swagger-parser reads as a path or URL.
$refs that point outside the document were followed too. A spec should only be read from the content or the URL the user gives us, and the URL goes throughassertSafeOutboundUrlfirst.Changes
parseSpec()rejects anything that does not decode to an object, with a clear message.resolve: { external: false, file: false, http: false }in all three calls, so it resolves only$refs inside the document.$refs no longer resolve them. Those need to be bundled into one file first.Same behaviour on Cloud and self-hosted.
Type
Testing
In
packages/backend:npx jest src/connectors/parsers/openapi.parser.spec.ts: 35 passed. Without the parser change, the two new tests for non-documents and external$refs fail.npx jest src/connectors: 80 suites, 1596 passed, 11 skipped.npx tsc --noEmit -p tsconfig.jsonandnpx eslinton the changed files: no errors.Checklist
npm test) (connector suites locally, full suite in CI)Related Issues
Found in the Cloud logs during the daily check.