Skip to content

fix(Parse): Solve remote references#74

Open
javi-jsb wants to merge 1 commit into
jormaechea:masterfrom
sngular:solve-remote-references
Open

fix(Parse): Solve remote references#74
javi-jsb wants to merge 1 commit into
jormaechea:masterfrom
sngular:solve-remote-references

Conversation

@javi-jsb

@javi-jsb javi-jsb commented Oct 6, 2023

Copy link
Copy Markdown

I switched from json-ref to swagger-parser.
json-ref wasn't resolving remote references, which caused errors when splitting your schema into different files.

swagger-parser resolves circular references using object references. PathsParser does not handle this case and will result in an infinite loop.

This solution replaces circular references with the provided default value if the number of circular references exceeds the specified depth limit.

Solves #72

@javi-jsb javi-jsb force-pushed the solve-remote-references branch from 9ee6113 to 3a1fb21 Compare October 17, 2023 06:31
@javi-jsb javi-jsb force-pushed the solve-remote-references branch 4 times, most recently from 389ab01 to 530beed Compare November 16, 2023 12:54
Swagger-parser resolves circular references with Object references. PathsParser does not handle this case and will result in an infinite loop.

fix(ajv-openapi)!: remove draft-04 support

To solve an error importing AJV when OpenAPI Mocker is used as API from another application, that is using higher versions of AJV
Error: Cannot find module 'ajv/lib/refs/json-schema-draft-04.json'
Require stack:
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/ajv-openapi/index.js
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/open-api-mocker/lib/schema-validator/index.js
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/open-api-mocker/lib/paths/path.js
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/open-api-mocker/lib/paths/parser.js
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/open-api-mocker/lib/paths/index.js
[private-path]/[app-using-open-api-mocker-with-higher-ajv-version]/node_modules/open-api-mocker/lib/open-api-mocker.js
@EdwardSalter

Copy link
Copy Markdown
Contributor

I've just come across the issue with open-api-mocker bombing out when it encounters a ciruclar reference.

I believe that it boils down to an outdated version of ajv causing the issue. This PR uses swagger-parser which in turns uses ajv@8 which seems to solve this issue.

Either way, it'd be good to have this merged and released to avoid us having to use github dependencies in our package.json files to fix these small issues.

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.

3 participants