-
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
fix(ls): process schema 'null' / 'nullable' depending on spec version #2982
Conversation
@@ -56,6 +57,7 @@ import thenNonIfLint from './then--non-if'; | |||
import thenTypeLint from './then--type'; | |||
import titleTypeLint from './title--type'; | |||
import typeTypeLint from './type--type'; | |||
import typeTypeLintOpenApi30 from './type--type-openapi-3-0'; |
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 consistent naming with the rest of config
import typeTypeLintOpenApi30 from './type--type-openapi-3-0'; | |
import typeTypeOpenAPI3_0Lint from './type--type-openapi-3-0'; |
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.
@char0n
this doesn't seem to be liked by linter:
Variable name typeTypeOpenAPI3_0Lint
must match one of the following formats: camelCase, PascalCase, UPPER_CASE
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.
Yep, we disable it inline as in
apidom/packages/apidom-ls/src/config/openapi/header/lint/content--allowed-fields-3-0.ts
Line 6 in c169eb3
// eslint-disable-next-line @typescript-eslint/naming-convention |
We use this convention for element names containing version numbers as well.
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
const nullableNotRecommendedLint: LinterMeta = { | ||
code: ApilintCodes.SCHEMA_EXAMPLE_DEPRECATED, |
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.
new code needs to be created and assigned here
const nullableNotRecommendedLint: LinterMeta = { | ||
code: ApilintCodes.SCHEMA_EXAMPLE_DEPRECATED, | ||
source: 'apilint', | ||
message: 'nullable has no special meaning, if not set on purpose use "type=null" instead', |
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.
value of type must always be string even in case of the null type. This will avoid some confusion that this message might trigger
message: 'nullable has no special meaning, if not set on purpose use "type=null" instead', | |
message: 'nullable has no special meaning, if not set on purpose use `type="null"` instead', |
@@ -120,6 +123,7 @@ const schemaLints = [ | |||
thenTypeLint, | |||
titleTypeLint, | |||
typeTypeLint, | |||
typeTypeLintOpenApi30, |
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.
typeTypeLintOpenApi30, | |
typeTypeOpenAPI3_0Lint, |
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
const typeTypeLintOpenApi30: 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.
const typeTypeLintOpenApi30: LinterMeta = { | |
const typeTypeOpenAPI3_0Lint: LinterMeta = { |
32def07
to
b83f9ea
Compare
Error code duplicates were uncovered by eslint related libs update. Closes swagger-api#2982 Closes swagger-api#2923
Differentiates behavior for type
null
validation/completion depending on spec/version, also add validation rule fornullable
adding hint for all asyncapi and openapi spec versions except openapi 3.0.x. AsyncAPI also included as users can typically come from openapi 3.0 when designing an AsyncAPI spec