-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ls): add allowed fields lint rule for OpenAPI 2.0 Schema Object (#…
- Loading branch information
Showing
5 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/apidom-ls/src/config/common/schema/lint/allowed-fields-openapi-2-0.ts
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,57 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2 } from '../../../openapi/target-specs'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const allowedFieldsOpenAPI2_0Lint: LinterMeta = { | ||
code: ApilintCodes.NOT_ALLOWED_FIELDS, | ||
source: 'apilint', | ||
message: 'Object includes not allowed fields', | ||
/** | ||
* Technically additional JSON Schema keywords can be present, they are just unsupported. | ||
* That's why we use Warning severity here instead of Error. | ||
*/ | ||
severity: DiagnosticSeverity.Warning, | ||
linterFunction: 'allowedFields', | ||
linterParams: [ | ||
[ | ||
'$ref', | ||
'format', | ||
'title', | ||
'description', | ||
'default', | ||
'multipleOf', | ||
'maximum', | ||
'exclusiveMaximum', | ||
'minimum', | ||
'exclusiveMinimum', | ||
'maxLength', | ||
'minLength', | ||
'pattern', | ||
'maxItems', | ||
'minItems', | ||
'uniqueItems', | ||
'maxProperties', | ||
'minProperties', | ||
'required', | ||
'enum', | ||
'type', | ||
'items', | ||
'allOf', | ||
'properties', | ||
'additionalProperties', | ||
'discriminator', | ||
'readOnly', | ||
'xml', | ||
'externalDocs', | ||
'example', | ||
], | ||
'x-', | ||
], | ||
marker: 'key', | ||
targetSpecs: OpenAPI2, | ||
}; | ||
|
||
export default allowedFieldsOpenAPI2_0Lint; |
63 changes: 63 additions & 0 deletions
63
packages/apidom-ls/src/config/common/schema/lint/allowed-fields-openapi-3-0.ts
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,63 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI30 } from '../../../openapi/target-specs'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const allowedFieldsOpenAPI3_0Lint: LinterMeta = { | ||
code: ApilintCodes.NOT_ALLOWED_FIELDS, | ||
source: 'apilint', | ||
message: 'Object includes not allowed fields', | ||
/** | ||
* Technically additional JSON Schema keywords can be present, they are just unsupported. | ||
* That's why we use Warning severity here instead of Error. | ||
*/ | ||
severity: DiagnosticSeverity.Warning, | ||
linterFunction: 'allowedFields', | ||
linterParams: [ | ||
[ | ||
'$ref', | ||
'title', | ||
'multipleOf', | ||
'maximum', | ||
'exclusiveMaximum', | ||
'minimum', | ||
'exclusiveMinimum', | ||
'maxLength', | ||
'minLength', | ||
'pattern', | ||
'maxItems', | ||
'minItems', | ||
'uniqueItems', | ||
'maxProperties', | ||
'minProperties', | ||
'required', | ||
'enum', | ||
'type', | ||
'allOf', | ||
'oneOf', | ||
'anyOf', | ||
'not', | ||
'items', | ||
'properties', | ||
'additionalProperties', | ||
'description', | ||
'format', | ||
'default', | ||
'nullable', | ||
'discriminator', | ||
'readOnly', | ||
'writeOnly', | ||
'xml', | ||
'externalDocs', | ||
'example', | ||
'deprecated', | ||
], | ||
'x-', | ||
], | ||
marker: 'key', | ||
targetSpecs: OpenAPI30, | ||
}; | ||
|
||
export default allowedFieldsOpenAPI3_0Lint; |
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