-
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 rules for OpenAPI 2.0 Response Object (#3627)
Refs #3607
- Loading branch information
Showing
14 changed files
with
200 additions
and
47 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
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
19 changes: 19 additions & 0 deletions
19
packages/apidom-ls/src/config/openapi/response/lint/allowed-fields-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,19 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2 } from '../../target-specs'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const allowedFields2_0Lint: LinterMeta = { | ||
code: ApilintCodes.NOT_ALLOWED_FIELDS, | ||
source: 'apilint', | ||
message: 'Object includes not allowed fields', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'allowedFields', | ||
linterParams: [['description', 'schema', 'headers', 'examples', '$ref'], 'x-'], | ||
marker: 'key', | ||
targetSpecs: OpenAPI2, | ||
}; | ||
|
||
export default allowedFields2_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
21 changes: 21 additions & 0 deletions
21
packages/apidom-ls/src/config/openapi/response/lint/examples--type.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,21 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2 } from '../../target-specs'; | ||
|
||
const examplesTypeLint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI2_RESPONSE_FIELD_EXAMPLES_TYPE, | ||
source: 'apilint', | ||
message: '"examples" must be an object', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintElementOrClass', | ||
linterParams: ['example'], | ||
marker: 'key', | ||
markerTarget: 'examples', | ||
target: 'examples', | ||
data: {}, | ||
targetSpecs: OpenAPI2, | ||
}; | ||
|
||
export default examplesTypeLint; |
21 changes: 21 additions & 0 deletions
21
packages/apidom-ls/src/config/openapi/response/lint/headers--type.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,21 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2 } from '../../target-specs'; | ||
|
||
const headersTypeLint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI2_RESPONSE_FIELD_HEADERS_TYPE, | ||
source: 'apilint', | ||
message: '"headers" must be an object', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintElementOrClass', | ||
linterParams: ['headers'], | ||
marker: 'key', | ||
markerTarget: 'headers', | ||
target: 'headers', | ||
data: {}, | ||
targetSpecs: OpenAPI2, | ||
}; | ||
|
||
export default headersTypeLint; |
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
Oops, something went wrong.