diff --git a/packages/apidom-ls/src/services/validation/linter-functions.ts b/packages/apidom-ls/src/services/validation/linter-functions.ts index 764da1c02a..935678a7ae 100644 --- a/packages/apidom-ls/src/services/validation/linter-functions.ts +++ b/packages/apidom-ls/src/services/validation/linter-functions.ts @@ -1015,14 +1015,13 @@ export const standardLinterfunctions: FunctionItem[] = [ functionName: 'apilintOpenAPIPathTemplateValid', function: (element: Element) => { if (isStringElement(element)) { - const parameterElements: ParameterElement[] = []; - const pathItemElement = (element.parent as MemberElement).value as ObjectElement; if (pathItemElement.length === 0) { return true; } + const parameterElements: ParameterElement[] = []; pathItemElement.forEach((operation) => { const parameters = (operation as OperationElement).get('parameters'); if (isArrayElement(parameters)) { diff --git a/packages/apidom-ls/test/fixtures/validation/oas/path-template-all-defined.yaml b/packages/apidom-ls/test/fixtures/validation/oas/path-template-all-defined.yaml index 295e6d3648..98dbc87f0b 100644 --- a/packages/apidom-ls/test/fixtures/validation/oas/path-template-all-defined.yaml +++ b/packages/apidom-ls/test/fixtures/validation/oas/path-template-all-defined.yaml @@ -2,12 +2,21 @@ 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/{baz}/test/{foo_id}/baz/{bar_id}: delete: summary: Delete foo bar baz - operationId: >- - deleteFooBarBaz + operationId: deleteFooBarBaz parameters: - name: foo_id in: path @@ -32,8 +41,7 @@ paths: /test/{foo_id}/{bar_id}: get: summary: Get test foo bar - operationId: >- - getTestFooBar + operationId: getTestFooBar parameters: - name: foo_id in: path @@ -48,3 +56,15 @@ paths: content: application/json: schema: {} + /reference/{test_id}/{baz_id}: + get: + summary: Get test bar + operationId: getReferenceTestBaz + parameters: + - $ref: '#/components/parameters/test_id' + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} diff --git a/packages/apidom-ls/test/validate.ts b/packages/apidom-ls/test/validate.ts index 2f59e04be7..5ef6ddce19 100644 --- a/packages/apidom-ls/test/validate.ts +++ b/packages/apidom-ls/test/validate.ts @@ -3403,14 +3403,21 @@ describe('apidom-ls-validate', function () { const result = await languageService.doValidation(doc, validationContext); const expected: Diagnostic[] = [ { - range: { start: { line: 5, character: 2 }, end: { line: 5, character: 43 } }, + range: { start: { line: 15, character: 2 }, end: { line: 15, character: 43 } }, message: 'path template expressions is not matched with Parameter Object(s)', severity: 1, code: 3040101, source: 'apilint', }, { - range: { start: { line: 31, character: 2 }, end: { line: 31, character: 25 } }, + range: { start: { line: 40, character: 2 }, end: { line: 40, character: 25 } }, + message: 'path template expressions is not matched with Parameter Object(s)', + severity: 1, + code: 3040101, + source: 'apilint', + }, + { + range: { start: { line: 58, character: 2 }, end: { line: 58, character: 31 } }, message: 'path template expressions is not matched with Parameter Object(s)', severity: 1, code: 3040101,