Skip to content

feat: integrate v2 ParserJS in validate command - #376

Merged
asyncapi-bot merged 5 commits into
asyncapi:masterfrom
magicmatatjahu:integrate-spectral
Jan 31, 2023
Merged

asyncapi-bot merged 5 commits into
asyncapi:masterfrom
magicmatatjahu:integrate-spectral

Conversation

@magicmatatjahu

@magicmatatjahu magicmatatjahu commented Oct 18, 2022 •

Copy link
Copy Markdown
Member
  • Integrate new ParserJS (with Spectral) in the validate command
  • Integrate new way of validation in other commands - user can see validation diagnostics in generate models and diff commands and determine if command should fail or should perform logic if diagnostics severity is allowed.
  • Write tests

Example input:

asyncapi validate ./test/specification.yaml --diagnostics-format stylish

Example output:

image

Related issue(s)
Part of asyncapi/parser-js#481

@magicmatatjahu magicmatatjahu added the enhancement New feature or request label Oct 18, 2022
@magicmatatjahu
magicmatatjahu marked this pull request as ready for review October 18, 2022 11:06
@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
0.0% 0.0% Duplication

Souvikns
Souvikns previously approved these changes Oct 19, 2022

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

Looks awesome, one thing to add, when we run the validate command and there is a governance issue it says File ./test/specification.yml and/or referenced documents have governance issues. but the file is valid, shouldn't it say that the file is valid but have governance issue.

@magicmatatjahu

magicmatatjahu commented Oct 19, 2022 •

Copy link
Copy Markdown
Member Author

@Souvikns So you wanna see something like:

File ./test/specification.yml is valid but have (and/or referenced documents) governance issues.

?

@Souvikns

Copy link
Copy Markdown
Member

I use cli to quickly check if the spec I am writing is valid, and yeah this would help

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@Souvikns Ok, good :) I will change that but before let's see what think about that @derberg

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@derberg ping 😄

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

just left 2 comments
other review will do tomorrow

Comment thread src/parser.ts Outdated
Comment on lines 7 to 8

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 is pretty risky to import these helpers from dist of the CLI.....breaking changes may hurt us later

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.

It will give you errors during the CLI build that these exports don't exist in the path. There is no other way, and creating these functions from scratch or copying them to our codebase is pointless. There is no good solution here and this is the least invasive.

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 should at least make sure that in package.json we do not allow ^ for spectral-cli dependency

Comment thread package.json Outdated

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.

and here we have the same problem we have with other PR from Jonas. This will be overwritten with next parser release back to 1.18

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

left just few comments

Comment thread scripts/fetch-asyncapi-example.js Outdated

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 candidate for Parser API 😉

Comment thread src/models/SpecificationFile.ts Outdated

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.

this one sounds weird, do not play well with what it returns

Comment thread test/commands/diff.test.ts Outdated

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.

when I run diff successfully I do not want to see diagnostics by default. When I run diff I'm interested with diff, unless files that I run through diff have errors and diff cannot run because of it

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

since asyncapi/.github#204 the bump.yml workflow is not going to be replicated in repositories that do not have get-global-node-release-workflows. This means that you can now easily update it in parser repository, in the master branch to make sure regular releases will not revert the version update that you did here. So in parser bump workflow you need to add cli to list of ignored repos

@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 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@derberg Ok, suggestions applied! Could you check again?

@derberg

derberg commented Jan 30, 2023

Copy link
Copy Markdown
Member

@magicmatatjahu can you address code smells?

@magicmatatjahu

magicmatatjahu commented Jan 30, 2023 •

Copy link
Copy Markdown
Member Author

@derberg You can check that we cannot address such an issues, because Modelina doesn't support in input parsed AsyncAPI document (but only in types) - in the logic we check that. However, that code is in HEAD on master https://github.com/asyncapi/cli/blob/master/src/commands/generate/models.ts#L164 so that code isn't added by my PR.

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

@magicmatatjahu right, thanks for point that out

@magicmatatjahu

magicmatatjahu commented Jan 30, 2023 •

Copy link
Copy Markdown
Member Author

@jonaslagoni Do you wanna check. I changed some code in models generation?

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

@magicmatatjahu not necessary, but now that I am here LGTM 👍

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@derberg asyncapi/parser-js#701 and asyncapi/parser-js#702 Could you check? Thanks!

@derberg derberg changed the title feat: integrate v2 ParserJS feat: integrate v2 ParserJS in validate command Jan 31, 2023
@derberg

derberg commented Jan 31, 2023

Copy link
Copy Markdown
Member

/rtm

@asyncapi-bot
asyncapi-bot merged commit fe5bf85 into asyncapi:master Jan 31, 2023
@asyncapi-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@magicmatatjahu
magicmatatjahu deleted the integrate-spectral branch January 31, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants