-
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(apidom-ls): lint parameter defined in path template
- Loading branch information
1 parent
2a83fd6
commit 7710ef2
Showing
8 changed files
with
299 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
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
23 changes: 23 additions & 0 deletions
23
packages/apidom-ls/src/config/openapi/parameter/lint/is-defined-within-path-template.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,23 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2, OpenAPI3 } from '../../target-specs'; | ||
|
||
const isDefinedWithinPathTemplate: LinterMeta = { | ||
code: ApilintCodes.OPENAPI2_PARAMETER_FIELD_IS_DEFINED_WITHIN_PATH_TEMPLATE, | ||
source: 'apilint', | ||
message: 'parameter is not defined within path template', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintOpenAPIParameterFieldIsDefinedWithinPathTemplate', | ||
marker: 'value', | ||
targetSpecs: [...OpenAPI2, ...OpenAPI3], | ||
conditions: [ | ||
{ | ||
function: 'apilintOpenAPIPathTemplateWellFormed', | ||
params: [true], | ||
}, | ||
], | ||
}; | ||
|
||
export default isDefinedWithinPathTemplate; |
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
39 changes: 39 additions & 0 deletions
39
...es/apidom-ls/test/fixtures/validation/oas/parameter-defined-within-path-template-2-0.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,39 @@ | ||
swagger: '2.0' | ||
info: | ||
title: Foo | ||
version: 0.1.0 | ||
parameters: | ||
test_id: | ||
name: test_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Test Id | ||
paths: | ||
/foo/{bar_id}: | ||
delete: | ||
summary: Delete foo bar id | ||
operationId: deleteFooBar | ||
parameters: | ||
- name: foo_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Foo Id | ||
- name: bar_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Bar Id | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} |
40 changes: 40 additions & 0 deletions
40
...es/apidom-ls/test/fixtures/validation/oas/parameter-defined-within-path-template-3-0.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,40 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Foo | ||
version: 0.1.0 | ||
components: | ||
parameters: | ||
test_id: | ||
name: test_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Test Id | ||
paths: | ||
/foo/{bar_id}: | ||
delete: | ||
summary: Delete foo bar id | ||
operationId: deleteFooBar | ||
parameters: | ||
- name: foo_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Foo Id | ||
- name: bar_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Bar Id | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} |
40 changes: 40 additions & 0 deletions
40
...es/apidom-ls/test/fixtures/validation/oas/parameter-defined-within-path-template-3-1.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,40 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Foo | ||
version: 0.1.0 | ||
components: | ||
parameters: | ||
test_id: | ||
name: test_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Test Id | ||
paths: | ||
/foo/{bar_id}: | ||
delete: | ||
summary: Delete foo bar id | ||
operationId: deleteFooBar | ||
parameters: | ||
- name: foo_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Foo Id | ||
- name: bar_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Bar Id | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} |
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