Skip to content

fix: clone input schemas before transforming them#276

Open
pvdbosch wants to merge 8 commits intoasyncapi:masterfrom
pvdbosch:fix/clone-schemas-for-transform
Open

fix: clone input schemas before transforming them#276
pvdbosch wants to merge 8 commits intoasyncapi:masterfrom
pvdbosch:fix/clone-schemas-for-transform

Conversation

@pvdbosch
Copy link
Copy Markdown

@pvdbosch pvdbosch commented Aug 14, 2025

Description

Transformation from OpenAPI to JSON draft4 schema modifies the input data, even though cloneSchema: true is used.
This leads to the bug described in #275 when the same schema is transformed multiple times during parsing.

This PR adds a deep clone step before the transformation, and a test case to validate the fix.

PR #279 is an alternative fix, which upgrades @openapi-contrib/openapi-schema-to-json-schema to resolve the issue, but there may be more risk there because it's a new major version of the dependency.

Related issue(s)

Resolves #275

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@pvdbosch pvdbosch changed the title Clone OpenAPI input schemas before transforming them fix: clone input schemas before transforming them Aug 14, 2025
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Dec 13, 2025
fmvilas
fmvilas previously approved these changes Mar 24, 2026
fmvilas and others added 2 commits March 24, 2026 16:32
- update asyncapi version (avoid warning not latest)
- sonar fix (unused constant)
@pvdbosch
Copy link
Copy Markdown
Author

I fixed a test that was failing after latest merge with master, but the test failing in the GitHub Actions build seems another one. Still a mystery to why it's failing because I can't reproduce it locally. I'm trying to investigate further.

structuredClone requires minimum Node 17
@pvdbosch
Copy link
Copy Markdown
Author

Tests are working now on my forked github build.

There were missing await statements in another test somehow interfering, and the node.js version also needed to be updated to a newer one that supports structuredClone. I set minimum version to Node.js 18, aligned with https://github.com/asyncapi/parser-js/blob/master/package.json

Could you review these latest changes?

@github-actions github-actions bot removed the stale label Mar 25, 2026
@sonarqubecloud
Copy link
Copy Markdown

@pvdbosch
Copy link
Copy Markdown
Author

@fmvilas , could you review this PR again? All tests should work now in the GitHub Actions build.

This PR is probably less risky than the alternative one in #279, because that one requires a major update of the openapi-schema-to-json-schema dependency with many changes. Other AsyncAPI components still seem to be using the older version.

This issue is quite a roadblock for Belgian Government organizations, because we have a lot of existing schemas in OpenAPI 3.0 format.

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.

[BUG] Parsing fails for schema that's referenced multiple times

2 participants