-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ls): temporary quick fix false positive for schema reference
- Loading branch information
Showing
10 changed files
with
195 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
30 changes: 30 additions & 0 deletions
30
packages/apidom-ls/src/config/common/schema/lint/all-of--type-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,30 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
/* | ||
TODO remove specific rule fo OAS 3.0 when underlying issue has been fixed (missing referenced-element in ref) | ||
see | ||
https://github.com/swagger-api/swagger-editor/issues/3722 | ||
https://github.com/swagger-api/swagger-editor/issues/4026 | ||
*/ | ||
const allOfTypeOpenApi30Lint: LinterMeta = { | ||
code: ApilintCodes.SCHEMA_ALLOF_OPENAPI_3_0, | ||
source: 'apilint', | ||
message: 'allOf must be a non-empty array of schemas', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintArrayOfElementsOrClasses', | ||
linterParams: [['schema', 'reference'], true], | ||
marker: 'key', | ||
target: 'allOf', | ||
data: {}, | ||
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 allOfTypeOpenApi30Lint; |
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
30 changes: 30 additions & 0 deletions
30
packages/apidom-ls/src/config/common/schema/lint/any-of--type-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,30 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
/* | ||
TODO remove specific rule fo OAS 3.0 when underlying issue has been fixed (missing referenced-element in ref) | ||
see | ||
https://github.com/swagger-api/swagger-editor/issues/3722 | ||
https://github.com/swagger-api/swagger-editor/issues/4026 | ||
*/ | ||
const anyOfTypeOpenApi30Lint: LinterMeta = { | ||
code: ApilintCodes.SCHEMA_ANYOF_OPENAPI_3_0, | ||
source: 'apilint', | ||
message: 'anyOf must be a non-empty array of schemas', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintArrayOfElementsOrClasses', | ||
linterParams: [['schema', 'reference'], true], | ||
marker: 'key', | ||
target: 'anyOf', | ||
data: {}, | ||
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 anyOfTypeOpenApi30Lint; |
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
30 changes: 30 additions & 0 deletions
30
packages/apidom-ls/src/config/common/schema/lint/one-of--type-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,30 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
|
||
/* | ||
TODO remove specific rule fo OAS 3.0 when underlying issue has been fixed (missing referenced-element in ref) | ||
see | ||
https://github.com/swagger-api/swagger-editor/issues/3722 | ||
https://github.com/swagger-api/swagger-editor/issues/4026 | ||
*/ | ||
const oneOfTypeOpenApi30Lint: LinterMeta = { | ||
code: ApilintCodes.SCHEMA_ONEOF_OPENAPI_3_0, | ||
source: 'apilint', | ||
message: 'oneOf must be a non-empty array of schemas', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintArrayOfElementsOrClasses', | ||
linterParams: [['schema', 'reference'], true], | ||
marker: 'key', | ||
target: 'oneOf', | ||
data: {}, | ||
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 oneOfTypeOpenApi30Lint; |
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
22 changes: 22 additions & 0 deletions
22
packages/apidom-ls/test/fixtures/validation/oas/issue-editor-3722.yaml
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,22 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: allOf with one subschema | ||
version: 0.0.1 | ||
paths: {} | ||
components: | ||
schemas: | ||
Foo: | ||
type: object | ||
BarAll: | ||
allOf: | ||
- $ref: '#/components/schemas/Foo' | ||
description: something something | ||
BarAny: | ||
anyOf: | ||
- $ref: '#/components/schemas/Foo' | ||
description: something something | ||
BarOne: | ||
oneOf: | ||
- $ref: '#/components/schemas/Foo' | ||
description: something something | ||
|
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