Skip to content

chore: migrate @asyncapi/openapi-schema-parser into the parser-js - #1213

Merged
princerajpoot20 merged 7 commits into
asyncapi:masterfrom
princerajpoot20:openapi-schema-parser-migration
Aug 6, 2026
Merged

princerajpoot20 merged 7 commits into
asyncapi:masterfrom
princerajpoot20:openapi-schema-parser-migration

Conversation

@princerajpoot20

@princerajpoot20 princerajpoot20 commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Related asyncapi/openapi-schema-parser#326

Sanity check

Script used

import { Parser } from '@asyncapi/parser';
import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';

const doc = `
asyncapi: 2.6.0
info:
  title: Smoke
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/vnd.oai.openapi;version=3.0.0'
        payload:
          type: object
          nullable: true
          properties:
            title:
              type: string
`;

const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());

const { document, diagnostics } = await parser.parse(doc);
const schemaErrors = diagnostics.filter((d) => d.code === 'asyncapi2-schemas');

console.log('document?', Boolean(document));
console.log('schema errors:', schemaErrors.length);
if (schemaErrors.length) console.log(schemaErrors);
process.exit(schemaErrors.length || !document ? 1 : 0);
Screenshot 2026-08-02 at 3 33 12 PM

Looks good.

@changeset-bot

changeset-bot Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2d5eb79

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/openapi-schema-parser Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@princerajpoot20

Copy link
Copy Markdown
Member Author

@AayushSaini101 ready for review

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@AayushSaini101

AayushSaini101 commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

QQ: @princerajpoot20
import { Parser } from '@asyncapi/parser';
import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser'; we are testing the script via importing the openapi-schema-parser' from the different location other than parser, can you add local testing where you can use the reference of the openapi-schema-parser from the location of the parser then perform operation thanks

@princerajpoot20

princerajpoot20 commented Aug 6, 2026 •

Copy link
Copy Markdown
Member Author

@AayushSaini101
In the monorepo, @asyncapi/openapi-schema-parser does not resolve to the published npm package when the script is run from the parser-js root. npm workspaces link it to the local package:

node_modules/@asyncapi/openapi-schema-parser -> ../../packages/openapi-schema-parser
So the smoke script with:

is already exercising the local code under packages/openapi-schema-parser (the same path next to packages/parser), not a registry install.

import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';
is already exercising the local code under packages/openapi-schema-parser (the same path next to packages/parser), not a registry install.

node_modules/@asyncapi/openapi-schema-parser
→ ../../packages/openapi-schema-parser (LOCAL)

@princerajpoot20

Copy link
Copy Markdown
Member Author

Here is a run script that mentions it explicitly:

import { createRequire } from 'node:module';
import { Parser } from '@asyncapi/parser';

const requireFromParser = createRequire(
  new URL('../packages/parser/package.json', import.meta.url)
);
const { OpenAPISchemaParser } = requireFromParser('../openapi-schema-parser/cjs/index.js');

const doc = `
asyncapi: 2.6.0
info:
  title: Smoke
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/vnd.oai.openapi;version=3.0.0'
        payload:
          type: object
          nullable: true
          properties:
            title:
              type: string
`;

const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());

const { document, diagnostics } = await parser.parse(doc);
const schemaErrors = diagnostics.filter((d) => d.code === 'asyncapi2-schemas');

console.log('import: relative from packages/parser -> ../openapi-schema-parser/cjs');
console.log('document?', Boolean(document));
console.log('schema errors:', schemaErrors.length);
if (schemaErrors.length) console.log(schemaErrors);
process.exit(schemaErrors.length || !document ? 1 : 0);

Result
Screenshot 2026-08-06 at 9 09 37 AM

@AayushSaini101

Copy link
Copy Markdown
Collaborator

Here is a run script that mentions it explicitly:

import { createRequire } from 'node:module';
import { Parser } from '@asyncapi/parser';

const requireFromParser = createRequire(
  new URL('../packages/parser/package.json', import.meta.url)
);
const { OpenAPISchemaParser } = requireFromParser('../openapi-schema-parser/cjs/index.js');

const doc = `
asyncapi: 2.6.0
info:
  title: Smoke
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/vnd.oai.openapi;version=3.0.0'
        payload:
          type: object
          nullable: true
          properties:
            title:
              type: string
`;

const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());

const { document, diagnostics } = await parser.parse(doc);
const schemaErrors = diagnostics.filter((d) => d.code === 'asyncapi2-schemas');

console.log('import: relative from packages/parser -> ../openapi-schema-parser/cjs');
console.log('document?', Boolean(document));
console.log('schema errors:', schemaErrors.length);
if (schemaErrors.length) console.log(schemaErrors);
process.exit(schemaErrors.length || !document ? 1 : 0);

Result Screenshot 2026-08-06 at 9 09 37 AM

thanks for the explanations @princerajpoot20 : )

@AayushSaini101 AayushSaini101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM : )

@princerajpoot20
princerajpoot20 merged commit ed5a42b into asyncapi:master Aug 6, 2026
10 checks passed
@github-actions github-actions Bot added the microgrant Participation in the Microgrant Program label Aug 7, 2026
@aeworxet

aeworxet commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@asyncapi/microgrant_team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

microgrant Participation in the Microgrant Program

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

3 participants