Skip to content

refactor: add AsyncAPI Schema Parser - #573

Merged
asyncapi-bot merged 7 commits into
asyncapi:next-majorfrom
smoya:feat/schemaParser
Jul 27, 2022
Merged

asyncapi-bot merged 7 commits into
asyncapi:next-majorfrom
smoya:feat/schemaParser

Conversation

@smoya

@smoya smoya commented Jul 21, 2022

Copy link
Copy Markdown
Member

Description

This PR adds the AsyncAPI Schema Parser, which is compatible with Spectral validation functions.

Related issue(s)
#480

@smoya
smoya marked this pull request as ready for review July 22, 2022 10:13
Comment thread src/types.ts Outdated

export type Diagnostic = ISpectralDiagnostic;
export type SchemaValidateResult = IFunctionResult;
export type SchemaValidateError = IFunctionResult;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed the name to be more explicit about what it is in fact... just an error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not always an error, because from spectral you can also return info or warning severity, by this spectral team called it IFunctionResult not IFunctionError. Please change to the previous one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rollbacked the rename! thanks for the catch

@magicmatatjahu magicmatatjahu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good, but we need some improvements :)

Comment thread package.json Resolved
Comment thread src/types.ts Outdated

export type Diagnostic = ISpectralDiagnostic;
export type SchemaValidateResult = IFunctionResult;
export type SchemaValidateError = IFunctionResult;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not always an error, because from spectral you can also return info or warning severity, by this spectral team called it IFunctionResult not IFunctionError. Please change to the previous one.

Comment thread src/types.ts Outdated
@@ -1,4 +1,5 @@
import type { ISpectralDiagnostic, IFunctionResult } from '@stoplight/spectral-core';
import { JSONSchema7 }from "json-schema"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
import { JSONSchema7 }from "json-schema"
import type { JSONSchema7 }from "json-schema"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, didn't commit. It is now, please check again.

@smoya
smoya force-pushed the feat/schemaParser branch from ec38404 to 30c0cb3 Compare July 27, 2022 10:50
* @param {Object} version AsyncAPI version.
* @returns {Object} valid JSON Schema document describing format of AsyncAPI-valid schema for message payload
*/
function preparePayloadSchema2(asyncapiSchema: AsyncAPISchema, version: string) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comes from #423

];
['2.0.0', '2.1.0', '2.2.0', '2.3.0'].forEach(version => {

specVersions.forEach((version: string) => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removing the need for adding a new version every time a new spec version is out...

@smoya
smoya requested a review from magicmatatjahu July 27, 2022 10:53

@magicmatatjahu magicmatatjahu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good, but we need some additional improvements :)

@smoya
smoya requested a review from magicmatatjahu July 27, 2022 13:28
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@magicmatatjahu

Copy link
Copy Markdown
Member

/rtm

@asyncapi-bot
asyncapi-bot merged commit d65e484 into asyncapi:next-major Jul 27, 2022
@smoya smoya mentioned this pull request Jul 27, 2022
14 of 20 tasks
@smoya
smoya deleted the feat/schemaParser branch August 25, 2022 09:08
magicmatatjahu pushed a commit to magicmatatjahu/parser-js that referenced this pull request Oct 3, 2022
derberg pushed a commit that referenced this pull request Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants