Skip to content

fix: safely alias schema properties and transform root xml to x-xml - #335

Open
RohithPariki wants to merge 1 commit into
asyncapi:masterfrom
RohithPariki:fix/safely-alias-props-and-xml
Open

fix: safely alias schema properties and transform root xml to x-xml#335
RohithPariki wants to merge 1 commit into
asyncapi:masterfrom
RohithPariki:fix/safely-alias-props-and-xml

Conversation

@RohithPariki

@RohithPariki RohithPariki commented Aug 29, 2026

Copy link
Copy Markdown

Description

This PR improves the schema traversal safety in iterateSchema and aliasProps within @asyncapi/openapi-schema-parser:

  1. Adds safety guards for non-object, null, or boolean schema values in iterateSchema and aliasProps. Previously, properties with primitive values, boolean schemas (e.g., additionalProperties: false, boolean items), or null values could cause TypeError when attempting property lookups.
  2. Supports converting xml to x-xml on top-level root schema objects in addition to nested properties.
  3. Adds automated unit tests covering XML property aliasing and safe handling of boolean/primitive schema values.

Changes Made

  • Added object validation guards in iterateSchema and aliasProps in src/index.ts.
  • Added root xml to x-xml aliasing in iterateSchema.
  • Added unit tests in test/parser.spec.ts.

Checks

  • npm test passes (9/9 tests pass) with 98.27% code coverage.
  • npm run lint passes with 0 warnings/errors.
  • npm run build succeeds (both ESM and CJS).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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.

@sonarqubecloud

Copy link
Copy Markdown

@RohithPariki
RohithPariki marked this pull request as ready for review August 29, 2026 02:07
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.

1 participant