Skip to content

fix(Parse): Solve remote references #74

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JavierSierraBlazquez
Copy link

@JavierSierraBlazquez JavierSierraBlazquez commented Oct 6, 2023

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

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
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