Skip to content

refactor: integrate custom schemas with parser and spectral - #579

Merged
asyncapi-bot merged 10 commits into
asyncapi:next-majorfrom
magicmatatjahu:next/integrate-custom-parsers
Aug 29, 2022
Merged

asyncapi-bot merged 10 commits into
asyncapi:next-majorfrom
magicmatatjahu:next/integrate-custom-parsers

Conversation

@magicmatatjahu

@magicmatatjahu magicmatatjahu commented Aug 24, 2022 •

Copy link
Copy Markdown
Member

Description

  • integrate custom schemas with parser and Spectral:
    • write custom Spectral rule to validate schemas
    • write logic to parse schemas
    • write unit tests

cc @smoya

Related issue(s)
Part of #482

@magicmatatjahu
magicmatatjahu force-pushed the next/integrate-custom-parsers branch from ef8a4d4 to 0826afe Compare August 25, 2022 09:55
@magicmatatjahu magicmatatjahu added the enhancement New feature or request label Aug 25, 2022
@magicmatatjahu
magicmatatjahu marked this pull request as ready for review August 25, 2022 14:17
@magicmatatjahu
magicmatatjahu force-pushed the next/integrate-custom-parsers branch from 6aad643 to 7676c9e Compare August 26, 2022 09:49
}

async function parseSchemaV2(parser: Parser, item: ToParseItem) {
item.value[xParserOriginalSchemaFormat] = item.input.schemaFormat;

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.

I see you are removing it but I can't see where we add xParserOriginalSchemaFormat value back.

@magicmatatjahu magicmatatjahu Aug 26, 2022 •

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.

We don't remove schemaFormat from message in custom parsers so we don't need to set it the extension. Is it clear?

@smoya smoya Aug 26, 2022 •

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.

Then we need remember to modify the README as well

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.

Ok, I will change it! :)

Comment thread src/parser.ts

// TODO: fix type
this.spectral.setRuleset(aasRuleset as any);
this.registerSchemaParser(AsyncAPISchemaParser());

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.

You can now register the other ones as all have been merged.

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.

No. As current solution, people need to register given format manually. For example, RAML works only on nodejs, so register RAML here will break browser compability.

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.

Oh, that's right! 👍 thanks

@magicmatatjahu
magicmatatjahu force-pushed the next/integrate-custom-parsers branch from dd89a9f to 9b1838b Compare August 29, 2022 08:02
@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

recommended: true,
given: [
// operations
'$.channels.*.[publish,subscribe].message',

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.

I just realized all those paths are tied to AsyncAPI Spec v2.x.x. How would we make it happen for v3.x.x ?

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.

By separate function, we can use different "formats" for rules in this same rulesets - one function for v2, another one for v3. Don't worry :)

@smoya smoya 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.

LGTM! Great job @magicmatatjahu 💯 🚀 🌔

@magicmatatjahu

Copy link
Copy Markdown
Member Author

/rtm

@asyncapi-bot
asyncapi-bot merged commit 1764391 into asyncapi:next-major Aug 29, 2022
@magicmatatjahu
magicmatatjahu deleted the next/integrate-custom-parsers branch August 29, 2022 10:51
@magicmatatjahu magicmatatjahu mentioned this pull request Aug 31, 2022
14 of 20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-to-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants