-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
refactor: add AsyncAPI Schema Parser #573
Conversation
src/types.ts
Outdated
@@ -16,4 +17,5 @@ export interface DetailedAsyncAPI { | |||
} | |||
|
|||
export type Diagnostic = ISpectralDiagnostic; | |||
export type SchemaValidateResult = IFunctionResult; | |||
export type SchemaValidateError = IFunctionResult; |
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 changed the name to be more explicit about what it is in fact... just an error.
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.
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.
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.
Rollbacked the rename! thanks for the catch
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.
Good, but we need some improvements :)
src/types.ts
Outdated
@@ -16,4 +17,5 @@ export interface DetailedAsyncAPI { | |||
} | |||
|
|||
export type Diagnostic = ISpectralDiagnostic; | |||
export type SchemaValidateResult = IFunctionResult; | |||
export type SchemaValidateError = IFunctionResult; |
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.
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.
src/types.ts
Outdated
@@ -1,4 +1,5 @@ | |||
import type { ISpectralDiagnostic, IFunctionResult } from '@stoplight/spectral-core'; | |||
import { JSONSchema7 }from "json-schema" |
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.
import { JSONSchema7 }from "json-schema" | |
import type { JSONSchema7 }from "json-schema" |
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.
Sorry, didn't commit. It is now, please check again.
* @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) { |
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.
Comes from #423
@@ -22,7 +94,8 @@ function getMimeTypes() { | |||
'application/schema+json;version=draft-07', | |||
'application/schema+yaml;version=draft-07', | |||
]; | |||
['2.0.0', '2.1.0', '2.2.0', '2.3.0'].forEach(version => { | |||
|
|||
specVersions.forEach((version: string) => { |
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.
Removing the need for adding a new version every time a new spec version is out...
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.
Good, but we need some additional improvements :)
Kudos, SonarCloud Quality Gate passed! |
/rtm |
Description
This PR adds the AsyncAPI Schema Parser, which is compatible with Spectral validation functions.
Related issue(s)
#480