-
Notifications
You must be signed in to change notification settings - Fork 18
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(apidom-ls): create schema rule for missing core keywords #3554
Conversation
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.
Looks good! We need to sort some cross specs details before we go for a merge.
...AsyncAPI250, | ||
...AsyncAPI260, | ||
]; | ||
export const AsyncAPI = [...AsyncAPI2]; |
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.
In light of 1e15838 can we remove this?
The reasoning is that we'd rather add target spec explicitly to what applies, then automatically activating existing rules for example for AsyncAPI 3.0 (when we're adding support for it). This total group of all AsyncAPI spec targets has no practical usage and causes more issues than it solves.
@@ -9,7 +9,7 @@ const additionalItemsTypeLint: LinterMeta = { | |||
message: 'additionalItems must be a schema', | |||
severity: DiagnosticSeverity.Error, | |||
linterFunction: 'apilintElementOrClass', | |||
linterParams: ['schema'], | |||
linterParams: ['schema', 'boolean'], |
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 cannot really do that. OpenAPI 2.0/3.0.x use JSON Schema Draft 4/5 which doesn't support Boolean JSON Schema
. Boolean JSON Schemas are supported since JSON Schema Draft 6 and applies to: AsyncAPI 2.x and OpenAPI 3.1.0 only.
We would have to fork this rule and use targetSpec
to apply it to appropriate specification and their versions.
Important
This applies to all modified rules in /common/schema/
@@ -0,0 +1,91 @@ | |||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; |
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.
Just to make naming consistent with the import symbol:
missing-core-fields-oas-3-0-asyncapi.ts
-> missing-core-fields-openapi-3-0-asyncapi-2.ts
import { AsyncAPI } from '../../../asyncapi/target-specs'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const missingCoreFieldsOpenAPI3_0AndAsyncAPILint: LinterMeta = { |
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.
IMHO this needs to be forked to multipe rules targeting different specs.
OpenAPI 2.0/3.0.x uses JSON Schema Draft 4/5 with following keywords: https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-json-schema-draft-4/src/elements/JSONSchema.ts#L35
AsyncAPI 2.x uses JSON Schema Draft 7 which:
Removes keywords: id
Add keywords: $id, contains, propertyNames, examples, $comment, if, then, else, contentEncoding, contentMediaType, media, writeOnly
OpenAPI 3.1 uses JSON Schema Draft 2020-12 with following keywords: https://github.com/swagger-api/apidom/blob/5b504e523c532a31aaf1b133a14ff3b76c126435/packages/apidom-ns-openapi-3-1/src/elements/Schema.ts
replaced by #3640 |
Refs #3549
Also fixes rules for JSON Schema type checks considering also boolean schemas