-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable validation of AsyncAPI Spec v3 documents in validate command #780
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b9f6fb3
feat: enable validation of AsyncAPI Spec v3 documents in validate com…
smoya 0527ff0
adapted tests
smoya e8137ff
Merge branch 'master' into feat/supportV3Validation
smoya 11ebcd1
Merge remote-tracking branch 'upstream/master' into pr/780
Souvikns 2c5d1a1
Update convert.ts
Souvikns 21ec32b
remove test.asyncapi-cli + add it to the .gitignore
smoya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; | ||
import { Flags } from '@oclif/core'; | ||
import { ConvertDocumentParserAPIVersion } from '@smoya/multi-parser'; | ||
import Command from '../../base'; | ||
import { load } from '../../models/SpecificationFile'; | ||
import { formatOutput, parse, validationFlags } from '../../parser'; | ||
|
@@ -161,6 +162,11 @@ export default class Models extends Command { | |
this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${formatOutput(severityErrors,'stylish','error')}`); | ||
return; | ||
} | ||
|
||
// Modelina, atm, is not using @asyncapi/[email protected] but @asyncapi/[email protected], so it still uses Parser-API v1.0.0. | ||
// This call converts the parsed document object using @asyncapi/[email protected] (Parser-API v2.0.0) to a document compatible with the Parser-API version in use in @asyncapi/[email protected] (v1.0.0) | ||
// This is needed until https://github.com/asyncapi/modelina/issues/1493 gets fixed. | ||
const convertedDoc = ConvertDocumentParserAPIVersion(document.json(), '1.0.0'); | ||
|
||
Logger.setLogger({ | ||
info: (message) => { | ||
|
@@ -314,7 +320,7 @@ export default class Models extends Command { | |
|
||
if (output) { | ||
const models = await fileGenerator.generateToFiles( | ||
document as any, | ||
convertedDoc as any, | ||
output, | ||
{ ...fileOptions, } as any); | ||
const generatedModels = models.map((model) => { return model.modelName; }); | ||
|
@@ -323,7 +329,7 @@ export default class Models extends Command { | |
} | ||
|
||
const models = await fileGenerator.generateCompleteModels( | ||
document as any, | ||
convertedDoc as any, | ||
{ ...fileOptions } as any); | ||
const generatedModels = models.map((model) => { | ||
return ` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"store":{}} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
asyncapi: 3.0.0 | ||
id: urn:some:company | ||
info: | ||
title: Account Service | ||
version: 1.0.0 | ||
description: This service is in charge of processing user signups | ||
license: | ||
name: Apache 2.0 | ||
url: https://www.apache.org/licenses/LICENSE-2.0 | ||
contact: | ||
name: API Support | ||
url: https://www.example.com/support | ||
email: [email protected] | ||
tags: | ||
- name: some-tag | ||
defaultContentType: 'application/json' | ||
servers: | ||
production: | ||
host: development.gigantic-server.com | ||
description: Development server | ||
protocol: kafka | ||
protocolVersion: '1.0.0' | ||
channels: | ||
UserSignedUp: | ||
address: 'user/signedup' | ||
messages: | ||
UserSignedUp: | ||
$ref: '#/components/messages/UserSignedUp' | ||
operations: | ||
UserSignedUp: | ||
description: User signedup | ||
action: 'send' | ||
channel: | ||
$ref: '#/channels/UserSignedUp' | ||
components: | ||
messages: | ||
UserSignedUp: | ||
messageId: UserSignedUp | ||
payload: | ||
type: object | ||
properties: | ||
displayName: | ||
type: string | ||
description: Name of the user | ||
email: | ||
type: string | ||
format: email | ||
description: Email of the user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed @Souvikns ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add it to the
gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!