-
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 lint rule for OpenAPI Parameter defined in path template (
- Loading branch information
1 parent
df7ab18
commit 2ab2840
Showing
8 changed files
with
391 additions
and
1 deletion.
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
17 changes: 17 additions & 0 deletions
17
packages/apidom-ls/src/config/openapi/parameter/lint/in-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,17 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2, OpenAPI3 } from '../../target-specs'; | ||
|
||
const inPathTemplateLint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI2_PARAMETER_FIELD_IN_PATH_TEMPLATE, | ||
source: 'apilint', | ||
message: 'parameter is not defined within path template', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintOpenAPIParameterInPathTemplate', | ||
marker: 'value', | ||
targetSpecs: [...OpenAPI2, ...OpenAPI3], | ||
}; | ||
|
||
export default inPathTemplateLint; |
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
42 changes: 42 additions & 0 deletions
42
...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,42 @@ | ||
swagger: '2.0' | ||
info: | ||
title: Foo | ||
version: 0.1.0 | ||
parameters: | ||
test_id: | ||
name: test_id | ||
in: path | ||
required: true | ||
type: string | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Test Id | ||
paths: | ||
/foo/{bar_id}: | ||
delete: | ||
summary: Delete bar id | ||
operationId: deleteBar | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} | ||
parameters: | ||
- name: foo_id | ||
in: path | ||
required: true | ||
type: string | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Foo Id | ||
- name: bar_id | ||
in: path | ||
required: true | ||
type: string | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Foo Id |
74 changes: 74 additions & 0 deletions
74
...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,74 @@ | ||
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 bar id | ||
operationId: deleteBar | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} | ||
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 | ||
/subscribe: | ||
post: | ||
description: subscribes a client | ||
responses: | ||
'201': | ||
description: subscription successfully created | ||
content: | ||
application/json: | ||
schema: {} | ||
callbacks: | ||
onData: | ||
'{$request.query.callbackUrl}/data': | ||
post: | ||
requestBody: | ||
description: subscription payload | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
userData: | ||
type: string | ||
parameters: | ||
- name: baz_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Baz Id | ||
responses: | ||
'202': | ||
description: "OK" | ||
|
92 changes: 92 additions & 0 deletions
92
...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,92 @@ | ||
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 | ||
webhooks: | ||
newWebhook: | ||
post: | ||
requestBody: | ||
description: new webook | ||
content: | ||
application/json: | ||
schema: {} | ||
parameters: | ||
- name: hook_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Hook Id | ||
responses: | ||
"200": | ||
description: OK | ||
paths: | ||
/foo/{bar_id}: | ||
delete: | ||
summary: Delete bar id | ||
operationId: deleteBar | ||
responses: | ||
'200': | ||
description: Successful Response | ||
content: | ||
application/json: | ||
schema: {} | ||
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 | ||
/subscribe: | ||
post: | ||
description: subscribes a client | ||
responses: | ||
'201': | ||
description: subscription successfully created | ||
content: | ||
application/json: | ||
schema: {} | ||
callbacks: | ||
onData: | ||
'{$request.query.callbackUrl}/data': | ||
post: | ||
requestBody: | ||
description: subscription payload | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
userData: | ||
type: string | ||
parameters: | ||
- name: baz_id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
format: uuid | ||
title: Baz Id | ||
responses: | ||
'202': | ||
description: "OK" |
Oops, something went wrong.