This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrite the whole parser (AGAIN) (#23)
* feat: add new @scalar/resolver package * chore: clean up * test: improve test:prepare error message * refactor: remove resolver package, integrate into the openapi parser (wip) * fix: references with whitespace * fix: invalid reference error message * test: use new invalid reference error message * test: disable file system tests * chore: clean up * chore: try to add some more tests * chore: add diff testing * chore: add failing test case * chore: make the example even simpler * chore: add some comments * feat: recursively resolve pointer reference before pushing to object * fix: pointers with white space can’t be resolved * chore: disable old test * fix: can’t access $ref of undefined * fix: references inside of arrays can’t be found * chore: disable old test * chore: test more real-world examples * fix: original properties are overwritten with the referenced content * chore: diff testing for more files * fix: existing properties are overwritten with referenced content * fix: referenced content loses reference to original object * fix: throws exception when the pointer does not exist * fix: $ref is not a string * chore: add failing max call stack example file (wip) * refactor: migrate checkReferences method * chore: rewrite resolve function to use less memory wip * refactor: rename basic test file * chore: add another test * refactor: write resolve function from scratch (wip) * refactor: write resolve function from scratch (wip) * refactor: rename findReference to resolveUri * fix: detect circular references and throw error * chore: resolve circular refs wip * fix: resolve circular references * chore: docstrings and cleanup * chore: update diff test invalid files list * chore: improve circular reference test * chore: rewrite the resolve function from scratch (again) * refactor: rewrite the resolve method *again* (wip) * refactor: minor bug fixes * test: output errors (if they appear) * chore: clean up * docs(changeset): refactor: rewrote the whole parser (again) * docs(changeset): fix: circular references can not be resolved * docs(changeset): fix: references inside references are not resolved * docs: update README * docs: add mentions to the README * chore: clean up * fix: ts errors --------- Co-authored-by: tmastrom <thomas.mastromonaco@gmail.com>
- Loading branch information
Showing
136 changed files
with
1,029 additions
and
6,789 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@scalar/openapi-parser": minor | ||
--- | ||
|
||
fix: circular references can not be resolved |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@scalar/openapi-parser": minor | ||
--- | ||
|
||
fix: references inside references are not resolved |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@scalar/openapi-parser": minor | ||
--- | ||
|
||
refactor: rewrote the whole parser (again) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
5 changes: 3 additions & 2 deletions
5
...rc/lib/Validator/resolveFromFilesystem.ts → ...alidator/_backup/resolveFromFilesystem.ts
This file contains 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
This file contains 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
5 changes: 3 additions & 2 deletions
5
...pi-parser/src/lib/Validator/resolveUri.ts → ...r/src/lib/Validator/_backup/resolveUri.ts
This file contains 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
106 changes: 65 additions & 41 deletions
106
packages/openapi-parser/src/lib/Validator/checkReferences.test.ts
This file contains 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
13 changes: 6 additions & 7 deletions
13
packages/openapi-parser/src/lib/Validator/checkReferences.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import type { Filesystem } from '../../types' | ||
import { AnyObject } from '../../types' | ||
import { resolveReferences } from './resolveReferences' | ||
import { transformErrors } from './transformErrors' | ||
|
||
export function checkReferences(filesystem: Filesystem) { | ||
const entrypoint = filesystem.find((file) => file.isEntrypoint === true) | ||
|
||
// TODO: Adapat for the new function | ||
export function checkReferences(specification: AnyObject) { | ||
try { | ||
resolveReferences(filesystem, false) | ||
resolveReferences(specification) | ||
|
||
return { | ||
valid: true, | ||
} | ||
} catch (err) { | ||
} catch (error) { | ||
return { | ||
valid: false, | ||
errors: transformErrors(entrypoint, err.message), | ||
errors: transformErrors(specification, error.message), | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './Validator' | ||
export * from './resolveReferences' |
5 changes: 0 additions & 5 deletions
5
packages/openapi-parser/src/lib/Validator/resolveFromFilesystem.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.