-
-
Notifications
You must be signed in to change notification settings - Fork 99
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: integrate custom schemas with parser and spectral #579
Changes from all commits
d36c9c6
af7dc29
b84b619
7761a66
caa8386
38750ec
eb58491
674eade
9b1838b
fd89383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Spectral } from "@stoplight/spectral-core"; | ||
import { asyncapi as aasRuleset } from "@stoplight/spectral-rulesets"; | ||
|
||
import { parse } from "./parse"; | ||
import { lint, validate } from "./lint"; | ||
import { registerSchemaParser } from './schema-parser'; | ||
import { AsyncAPISchemaParser } from "./schema-parser/asyncapi-schema-parser"; | ||
import { configureSpectral } from "./spectral"; | ||
|
||
import type { IConstructorOpts } from "@stoplight/spectral-core"; | ||
import type { ParseInput, ParseOptions } from "./parse"; | ||
|
@@ -18,16 +19,18 @@ export class Parser { | |
public readonly parserRegistry = new Map<string, SchemaParser>(); | ||
public readonly spectral: Spectral; | ||
|
||
constructor(options?: ParserOptions) { | ||
const { spectral } = options || {}; | ||
constructor( | ||
private readonly options?: ParserOptions | ||
) { | ||
const { spectral } = this.options || {}; | ||
if (spectral instanceof Spectral) { | ||
this.spectral = spectral; | ||
} else { | ||
this.spectral = new Spectral(spectral); | ||
} | ||
|
||
// TODO: fix type | ||
this.spectral.setRuleset(aasRuleset as any); | ||
this.registerSchemaParser(AsyncAPISchemaParser()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can now register the other ones as all have been merged. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's right! 👍 thanks |
||
configureSpectral(this); | ||
} | ||
|
||
parse(asyncapi: ParseInput, options?: ParseOptions) { | ||
|
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 see you are removing it but I can't see where we add
xParserOriginalSchemaFormat
value back.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.
We don't remove schemaFormat from message in custom parsers so we don't need to set it the extension. Is it clear?
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.
Then we need remember to modify the README as well
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.
Ok, I will change it! :)