-
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.
fix(ls): add lint rule for OpenAPI 3.x.y Header.content field (#2388)
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
packages/apidom-ls/src/config/openapi/header/lint/content--allowed-fields-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,33 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const contentAllowedFields3_0Lint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI3_0_HEADER_FIELD_CONTENT_ALLOWED_FIELDS, | ||
source: 'apilint', | ||
message: | ||
'If "content" field is present, following fields are not allowed: style, explode, allowReserved, example and examples', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'allowedFields', | ||
linterParams: [ | ||
['description', 'required', 'deprecated', 'allowEmptyValue', 'schema', 'content', '$ref'], | ||
'x-', | ||
], | ||
marker: 'key', | ||
conditions: [ | ||
{ | ||
function: 'existFields', | ||
params: [['content']], | ||
}, | ||
], | ||
targetSpecs: [ | ||
{ namespace: 'openapi', version: '3.0.0' }, | ||
{ namespace: 'openapi', version: '3.0.1' }, | ||
{ namespace: 'openapi', version: '3.0.2' }, | ||
{ namespace: 'openapi', version: '3.0.3' }, | ||
], | ||
}; | ||
|
||
export default contentAllowedFields3_0Lint; |
32 changes: 32 additions & 0 deletions
32
packages/apidom-ls/src/config/openapi/header/lint/content--allowed-fields-3-1.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,32 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const contentAllowedFields3_1Lint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI3_1_HEADER_FIELD_CONTENT_ALLOWED_FIELDS, | ||
source: 'apilint', | ||
message: | ||
'If "content" field is present, following fields are not allowed: style, explode, allowReserved, example and examples', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'allowedFields', | ||
linterParams: [ | ||
['description', 'required', 'deprecated', 'allowEmptyValue', 'schema', 'content'], | ||
'x-', | ||
], | ||
marker: 'key', | ||
conditions: [ | ||
{ | ||
function: 'existFields', | ||
params: [['content']], | ||
}, | ||
{ | ||
function: 'missingField', | ||
params: ['$ref'], | ||
}, | ||
], | ||
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], | ||
}; | ||
|
||
export default contentAllowedFields3_1Lint; |
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