From a27fed5c39cb9e422b6b61b7aa6c159454895f4b Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Mon, 24 Oct 2022 14:29:26 +0200 Subject: [PATCH 1/4] feat(ls): provide OpenAPI 3.0.x Link docs rules Refs #2031 --- .../src/config/openapi/link/documentation.ts | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/packages/apidom-ls/src/config/openapi/link/documentation.ts b/packages/apidom-ls/src/config/openapi/link/documentation.ts index ec4efd31e..f06f08d8c 100644 --- a/packages/apidom-ls/src/config/openapi/link/documentation.ts +++ b/packages/apidom-ls/src/config/openapi/link/documentation.ts @@ -1,4 +1,24 @@ +/** + * Omitted fixed fields: + * - server + * + * Field omission reason: omitted fields do have a non-union type. Thus, + * documentation for these fields doesn't need to be specified here and will + * come directly from the type itself. Description of these fields doesn't + * contain significant information. + */ + const documentation = [ + { + target: 'operationRef', + docs: 'A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject) in the OpenAPI definition.', + 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' }, + ], + }, { target: 'operationRef', docs: 'A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operationObject) in the OpenAPI definition. See the rules for resolving [Relative References](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relativeReferencesURI).', @@ -8,11 +28,31 @@ const documentation = [ target: 'operationId', docs: 'The name of an existing, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field.', }, + { + target: 'parameters', + docs: 'Map[`string`, Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)]\n\\\n\\\nA map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).', + 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' }, + ], + }, { target: 'parameters', docs: 'Map[`string`, Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression)]\n\\\n\\\nA map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).', targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], }, + { + target: 'requestBody', + docs: 'Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)\n\\\n\\\nA literal value or [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) to use as a request body when calling the target operation.', + 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' }, + ], + }, { target: 'requestBody', docs: 'Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression)\n\\\n\\\nA literal value or [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) to use as a request body when calling the target operation.', @@ -22,15 +62,15 @@ const documentation = [ target: 'description', docs: 'A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.', }, - /** - * The following Fixed Field is provided as reference, but are more - * comprehensively described by parent Server Object meta documentation - */ - // { - // target: 'server', - // docs: '#### [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#serverObject)\n\nA server object to be used by the target operation.', - // targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], - // }, + { + docs: "#### [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md)\n\nThe `Link object` represents a possible design-time link for a response.\nThe presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.\n\nUnlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response.\n\nFor computing links, and providing instructions to execute them, a [runtime expression](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation.\n\n##### Fixed Fields\n\nField Name | Type | Description\n---|:---:|---\noperationRef | `string` | A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject) in the OpenAPI definition.\noperationId | `string` | The name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field.\nparameters | Map[`string`, Any \\| [{expression}](#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).\nrequestBody | Any \\| [{expression}](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) | A literal value or [{expression}](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) to use as a request body when calling the target operation.\ndescription | `string` | A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nserver | [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject) | A server object to be used by the target operation.\n\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions).\n\nA linked operation MUST be identified using either an `operationRef` or `operationId`.\nIn the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document.\nBecause of the potential for name clashes, the `operationRef` syntax is preferred\nfor specifications with external references.\n\n##### Examples\n\nComputing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation.\n\n\n\\\nYAML\n```yaml\npaths:\n /users/{id}:\n parameters:\n - name: id\n in: path\n required: true\n description: the user identifier, as userId\n schema:\n type: string\n get:\n responses:\n '200':\n description: the user being returned\n content:\n application/json:\n schema:\n type: object\n properties:\n uuid: # the unique user id\n type: string\n format: uuid\n links:\n address:\n # the target link operationId\n operationId: getUserAddress\n parameters:\n # get the `id` field from the request path parameter named `id`\n userId: $request.path.id\n # the path item of the linked operation\n /users/{userid}/address:\n parameters:\n - name: userid\n in: path\n required: true\n description: the user identifier, as userId\n schema:\n type: string\n # linked operation\n get:\n operationId: getUserAddress\n responses:\n '200':\n description: the user's address\n```\n\nWhen a runtime expression fails to evaluate, no parameter value is passed to the target operation.\n\nValues from the response body can be used to drive a linked operation.\n\n```yaml\nlinks:\n address:\n operationId: getUserAddressByUUID\n parameters:\n # get the `uuid` field from the `uuid` field in the response body\n userUuid: $response.body#/uuid\n```\n\nClients follow all links at their discretion.\nNeither permissions, nor the capability to make a successful call to that link, is guaranteed\nsolely by the existence of a relationship.", + 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' }, + ], + }, { docs: "#### [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#linkObject)\nThe `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.\n\n\\\nUnlike *dynamic* links (i.e.links provided in the response payload), the OAS linking mechanism does not require link information in the runtime response.\n\n\\\nFor computing links, and providing instructions to execute them, a [runtime expression](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) is used for accessing values in an operation and using them as parameters while invoking the linked operation.\n\n##### Fixed Fields\n\nField Name | Type | Description\n---|:---:|---\noperationRef | `string` | A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operationObject) in the OpenAPI definition. See the rules for resolving [Relative References](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relativeReferencesURI).\noperationId | `string` | The name of an existing, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field.\nparameters | Map[`string`, Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression)] | A map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).\nrequestBody | Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) | A literal value or [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) to use as a request body when calling the target operation.\ndescription | `string` | A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nserver | [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#serverObject) | A server object to be used by the target operation.\n\n\\\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specificationExtensions).\n\n\\\nA linked operation MUST be identified using either an `operationRef` or `operationId`. In the case of an `operationId`, it MUST be unique and resolved in the scope of the OAS document. Because of the potential for name clashes, the `operationRef` syntax is preferred for OpenAPI documents with external references.\n\n##### Examples\n\nComputing a link from a request operation where the `$request.path.id` is used to pass a request parameter to the linked operation.\n\n\\\nYAML\n```yaml\npaths:\n /users/{id}:\n parameters:\n - name: id\n in: path\n required: true\n description: the user identifier, as userId \n schema:\n type: string\n get:\n responses:\n '200':\n description: the user being returned\n content:\n application/json:\n schema:\n type: object\n properties:\n uuid: # the unique user id\n type: string\n format: uuid\n links:\n address:\n # the target link operationId\n operationId: getUserAddress\n parameters:\n # get the `id` field from the request path parameter named `id`\n userId: $request.path.id\n # the path item of the linked operation\n /users/{userid}/address:\n parameters:\n - name: userid\n in: path\n required: true\n description: the user identifier, as userId \n schema:\n type: string\n # linked operation\n get:\n operationId: getUserAddress\n responses:\n '200':\n description: the user's address\n```\n\n\\\nWhen a runtime expression fails to evaluate, no parameter value is passed to the target operation.\n\n\\\nValues from the response body can be used to drive a linked operation.\n\n\\\nYAML\n```yaml\nlinks:\n address:\n operationId: getUserAddressByUUID\n parameters:\n # get the `uuid` field from the `uuid` field in the response body\n userUuid: $response.body#/uuid\n```\n\n##### OperationRef Examples\n\nAs references to `operationId` MAY NOT be possible (the operationId is an optional field in an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operationObject)), references MAY also be made through a relative `operationRef`:\n\n\\\nYAML\n```yaml\nlinks:\n UserRepositories:\n # returns array of '#/components/schemas/repository'\n operationRef: '#/paths/~12.0~1repositories~1{username}/get'\n parameters:\n username: $response.body#/username\n```\n\n\\\nor an absolute `operationRef`:\n\n\\\nYAML\n```yaml\nlinks:\n UserRepositories:\n # returns array of '#/components/schemas/repository'\n operationRef: 'https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1{username}/get'\n parameters:\n username: $response.body#/username\n```\n\n\\\nNote that in the use of `operationRef`, the *escaped forward-slash* is necessary when using JSON references.", targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], From dbcec9bccb23b4a3da273fa10e8854fb0a75ce81 Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Mon, 24 Oct 2022 14:43:10 +0200 Subject: [PATCH 2/4] feat(ls): provide OpenAPI 3.0.x Link completion rules Refs #2032 --- .../src/config/openapi/link/completion.ts | 106 ++++++++++++++++++ .../apidom-ls/src/config/openapi/link/meta.ts | 2 + 2 files changed, 108 insertions(+) create mode 100644 packages/apidom-ls/src/config/openapi/link/completion.ts diff --git a/packages/apidom-ls/src/config/openapi/link/completion.ts b/packages/apidom-ls/src/config/openapi/link/completion.ts new file mode 100644 index 000000000..daaca11fb --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/completion.ts @@ -0,0 +1,106 @@ +import { + ApidomCompletionItem, + CompletionFormat, + CompletionType, +} from '../../../apidom-language-types'; + +const completion: ApidomCompletionItem[] = [ + { + label: 'operationRef', + insertText: 'operationRef', + kind: 14, + format: CompletionFormat.QUOTED, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + 'A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject) in the OpenAPI definition.', + }, + 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' }, + ], + }, + { + label: 'operationId', + insertText: 'operationId', + kind: 14, + format: CompletionFormat.QUOTED, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + 'The name of an existing, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field.', + }, + }, + { + label: 'parameters', + insertText: 'parameters', + kind: 14, + format: CompletionFormat.OBJECT, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + 'Map[`string`, Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)]\n\\\n\\\nA map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).', + }, + 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' }, + ], + }, + { + label: 'requestBody', + insertText: 'requestBody', + kind: 14, + format: CompletionFormat.QUOTED, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + 'Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)\n\\\n\\\nA literal value or [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) to use as a request body when calling the target operation.', + }, + 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' }, + ], + }, + { + label: 'description', + insertText: 'description', + kind: 14, + format: CompletionFormat.QUOTED, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + 'A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.', + }, + }, + { + label: 'server', + insertText: 'server', + kind: 14, + format: CompletionFormat.OBJECT, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + '[Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject)\n\\\n\\\nA server object to be used by the target operation.', + }, + }, +]; + +export default completion; diff --git a/packages/apidom-ls/src/config/openapi/link/meta.ts b/packages/apidom-ls/src/config/openapi/link/meta.ts index 33a6f7969..7ad2bb2ca 100644 --- a/packages/apidom-ls/src/config/openapi/link/meta.ts +++ b/packages/apidom-ls/src/config/openapi/link/meta.ts @@ -1,7 +1,9 @@ +import completion from './completion'; import documentation from './documentation'; import { FormatMeta } from '../../../apidom-language-types'; const meta: FormatMeta = { + completion, documentation, }; From 4498e5534d147e883d99a809d256ab1919d96f03 Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Mon, 24 Oct 2022 14:52:00 +0200 Subject: [PATCH 3/4] fix(ls): fix error code enum consistency for OpenAPI 3.0.x Refs #2033 --- packages/apidom-ls/src/config/codes.ts | 46 +++++++++---------- .../discriminator/lint/mapping--type.ts | 2 +- .../lint/property-name--required.ts | 2 +- .../discriminator/lint/property-name--type.ts | 2 +- .../reference/lint/$ref--format-uri.ts | 2 +- .../reference/lint/$ref--no-siblings-3-0.ts | 2 +- .../lint/bearer-format--type.ts | 2 +- .../security-scheme/lint/description--type.ts | 2 +- .../security-scheme/lint/flows--required.ts | 2 +- .../security-scheme/lint/flows--type.ts | 2 +- .../security-scheme/lint/in--equals.ts | 2 +- .../security-scheme/lint/in--required.ts | 2 +- .../security-scheme/lint/name--required.ts | 2 +- .../security-scheme/lint/name--type.ts | 2 +- .../lint/open-id-connect-url--format-uri.ts | 2 +- .../lint/open-id-connect-url--required.ts | 2 +- .../security-scheme/lint/scheme--type.ts | 2 +- .../security-scheme/lint/type--equals-3-0.ts | 2 +- 18 files changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index dd85c650d..94275484e 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -763,29 +763,29 @@ enum ApilintCodes { OPENAPI3_0_XML_FIELD_ATTRIBUTE_TYPE = 5230400, OPENAPI3_0_XML_FIELD_WRAPPED_TYPE = 5230500, - OPENAPI3_SECURITY_SCHEME = 5240000, - OPENAPI3_SECURITY_SCHEME_FIELD_TYPE_EQUALS = 5240100, - OPENAPI3_SECURITY_SCHEME_FIELD_DESCRIPTION_TYPE = 5240200, - OPENAPI3_SECURITY_SCHEME_FIELD_NAME_TYPE = 5240300, - OPENAPI3_SECURITY_SCHEME_FIELD_NAME_REQUIRED, - OPENAPI3_SECURITY_SCHEME_FIELD_IN_EQUALS = 5240400, - OPENAPI3_SECURITY_SCHEME_FIELD_IN_REQUIRED, - OPENAPI3_SECURITY_SCHEME_FIELD_SCHEME_TYPE = 5240500, - OPENAPI3_SECURITY_SCHEME_FIELD_SCHEME_REQUIRED, - OPENAPI3_SECURITY_SCHEME_FIELD_BEARER_FORMAT_TYPE = 5240600, - OPENAPI3_SECURITY_SCHEME_FIELD_FLOWS_TYPE = 5240700, - OPENAPI3_SECURITY_SCHEME_FIELD_FLOWS_REQUIRED, - OPENAPI3_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_FORMAT_URI = 5240800, - OPENAPI3_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_REQUIRED, - - OPENAPI3_DISCRIMINATOR = 5250000, - OPENAPI3_DISCRIMINATOR_FIELD_PROPERTY_NAME_TYPE = 5250100, - OPENAPI3_DISCRIMINATOR_FIELD_PROPERTY_NAME_REQUIRED, - OPENAPI3_DISCRIMINATOR_FIELD_MAPPING_TYPE = 5250200, - - OPENAPI3_REFERENCE = 5260000, - OPENAPI3_REFERENCE_FIELD_$REF_FORMAT_URI = 5260100, - OPENAPI3_REFERENCE_FIELD_$REF_NO_SIBLINGS, + OPENAPI3_0_SECURITY_SCHEME = 5240000, + OPENAPI3_0_SECURITY_SCHEME_FIELD_TYPE_EQUALS = 5240100, + OPENAPI3_0_SECURITY_SCHEME_FIELD_DESCRIPTION_TYPE = 5240200, + OPENAPI3_0_SECURITY_SCHEME_FIELD_NAME_TYPE = 5240300, + OPENAPI3_0_SECURITY_SCHEME_FIELD_NAME_REQUIRED, + OPENAPI3_0_SECURITY_SCHEME_FIELD_IN_EQUALS = 5240400, + OPENAPI3_0_SECURITY_SCHEME_FIELD_IN_REQUIRED, + OPENAPI3_0_SECURITY_SCHEME_FIELD_SCHEME_TYPE = 5240500, + OPENAPI3_0_SECURITY_SCHEME_FIELD_SCHEME_REQUIRED, + OPENAPI3_0_SECURITY_SCHEME_FIELD_BEARER_FORMAT_TYPE = 5240600, + OPENAPI3_0_SECURITY_SCHEME_FIELD_FLOWS_TYPE = 5240700, + OPENAPI3_0_SECURITY_SCHEME_FIELD_FLOWS_REQUIRED, + OPENAPI3_0_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_FORMAT_URI = 5240800, + OPENAPI3_0_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_REQUIRED, + + OPENAPI3_0_DISCRIMINATOR = 5250000, + OPENAPI3_0_DISCRIMINATOR_FIELD_PROPERTY_NAME_TYPE = 5250100, + OPENAPI3_0_DISCRIMINATOR_FIELD_PROPERTY_NAME_REQUIRED, + OPENAPI3_0_DISCRIMINATOR_FIELD_MAPPING_TYPE = 5250200, + + OPENAPI3_0_REFERENCE = 5260000, + OPENAPI3_0_REFERENCE_FIELD_$REF_FORMAT_URI = 5260100, + OPENAPI3_0_REFERENCE_FIELD_$REF_NO_SIBLINGS, OPENAPI3_1 = 7000000, diff --git a/packages/apidom-ls/src/config/openapi/discriminator/lint/mapping--type.ts b/packages/apidom-ls/src/config/openapi/discriminator/lint/mapping--type.ts index 5cbca387a..95dddc6d9 100644 --- a/packages/apidom-ls/src/config/openapi/discriminator/lint/mapping--type.ts +++ b/packages/apidom-ls/src/config/openapi/discriminator/lint/mapping--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const mappingTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_DISCRIMINATOR_FIELD_MAPPING_TYPE, + code: ApilintCodes.OPENAPI3_0_DISCRIMINATOR_FIELD_MAPPING_TYPE, source: 'apilint', message: "'mapping' must be an object", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--required.ts b/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--required.ts index 99e2aca06..eb0e93e35 100644 --- a/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--required.ts +++ b/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const propertyNameRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_DISCRIMINATOR_FIELD_PROPERTY_NAME_REQUIRED, + code: ApilintCodes.OPENAPI3_0_DISCRIMINATOR_FIELD_PROPERTY_NAME_REQUIRED, source: 'apilint', message: "should always have a 'propertyName'", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--type.ts b/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--type.ts index 888f639a6..79640fa03 100644 --- a/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--type.ts +++ b/packages/apidom-ls/src/config/openapi/discriminator/lint/property-name--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const propertyNameTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_DISCRIMINATOR_FIELD_PROPERTY_NAME_TYPE, + code: ApilintCodes.OPENAPI3_0_DISCRIMINATOR_FIELD_PROPERTY_NAME_TYPE, source: 'apilint', message: "'propertyName' must be a string", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/reference/lint/$ref--format-uri.ts b/packages/apidom-ls/src/config/openapi/reference/lint/$ref--format-uri.ts index 0a2ac96c3..7e90107f8 100644 --- a/packages/apidom-ls/src/config/openapi/reference/lint/$ref--format-uri.ts +++ b/packages/apidom-ls/src/config/openapi/reference/lint/$ref--format-uri.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const $refFormatURILint: LinterMeta = { - code: ApilintCodes.OPENAPI3_REFERENCE_FIELD_$REF_FORMAT_URI, + code: ApilintCodes.OPENAPI3_0_REFERENCE_FIELD_$REF_FORMAT_URI, source: 'apilint', message: "'$ref' value must be a valid URI-reference", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/reference/lint/$ref--no-siblings-3-0.ts b/packages/apidom-ls/src/config/openapi/reference/lint/$ref--no-siblings-3-0.ts index fe3c683fd..cb2c72bbc 100644 --- a/packages/apidom-ls/src/config/openapi/reference/lint/$ref--no-siblings-3-0.ts +++ b/packages/apidom-ls/src/config/openapi/reference/lint/$ref--no-siblings-3-0.ts @@ -3,7 +3,7 @@ import { LinterMeta } from '../../../../apidom-language-types'; // eslint-disable-next-line @typescript-eslint/naming-convention const $refNoSiblings3_0Lint: LinterMeta = { - code: ApilintCodes.OPENAPI3_REFERENCE_FIELD_$REF_NO_SIBLINGS, + code: ApilintCodes.OPENAPI3_0_REFERENCE_FIELD_$REF_NO_SIBLINGS, source: 'apilint', message: 'All other properties in a "$ref" object are ignored', severity: 2, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/bearer-format--type.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/bearer-format--type.ts index 5b5edd041..69c7f53d8 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/bearer-format--type.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/bearer-format--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const bearerFormatTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_BEARER_FORMAT_TYPE, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_BEARER_FORMAT_TYPE, source: 'apilint', message: 'bearerFormat must be a string', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/description--type.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/description--type.ts index 16f7f7c7e..5857e737a 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/description--type.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/description--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const descriptionTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_DESCRIPTION_TYPE, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_DESCRIPTION_TYPE, source: 'apilint', message: 'description must be a string', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--required.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--required.ts index 70e84bde5..8d057fb06 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--required.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const flowsRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_FLOWS_REQUIRED, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_FLOWS_REQUIRED, source: 'apilint', message: "should always have a 'flows'", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--type.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--type.ts index 41a6a77ec..a7f30b945 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--type.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const flowsTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_FLOWS_TYPE, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_FLOWS_TYPE, source: 'apilint', message: 'flows must be an object', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--equals.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--equals.ts index 00efbdb57..5eb5166e7 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--equals.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--equals.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const inEqualsLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_IN_EQUALS, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_IN_EQUALS, source: 'apilint', message: "'in' must be one of allowed values", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--required.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--required.ts index c719fbf15..b696b7e5f 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--required.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/in--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const inRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_IN_REQUIRED, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_IN_REQUIRED, source: 'apilint', message: "should always have a 'in'", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--required.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--required.ts index 416c221a0..0dda5b2c5 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--required.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const nameRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_NAME_REQUIRED, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_NAME_REQUIRED, source: 'apilint', message: "should always have a 'name'", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--type.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--type.ts index 9d7ed6de4..0800b3e45 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--type.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/name--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const nameTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_NAME_TYPE, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_NAME_TYPE, source: 'apilint', message: 'name must be a string', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--format-uri.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--format-uri.ts index 418f5e0a3..6fef008cd 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--format-uri.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--format-uri.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const openIdConnectUrlFormatURILint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_FORMAT_URI, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_FORMAT_URI, source: 'apilint', message: 'openIdConnectUrl MUST be in the format of an absolute URL.', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--required.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--required.ts index 6e6f3c9af..ea12cf032 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--required.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const openIdConnectUrlRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_REQUIRED, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_OPEN_ID_CONNECT_URL_REQUIRED, source: 'apilint', message: "should always have a 'openIdConnectUrl'", severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--type.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--type.ts index 777f37117..3fc3cd863 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--type.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--type.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const schemeTypeLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_SCHEME_TYPE, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_SCHEME_TYPE, source: 'apilint', message: 'scheme must be a string', severity: 1, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-0.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-0.ts index 5e2ff39c5..b93d06cbb 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-0.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-0.ts @@ -3,7 +3,7 @@ import { LinterMeta } from '../../../../apidom-language-types'; // eslint-disable-next-line @typescript-eslint/naming-convention const typeEquals3_0Lint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_TYPE_EQUALS, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_TYPE_EQUALS, source: 'apilint', message: 'type must be one of allowed values', severity: 1, From 14baa34b04e956c24781f1a98862bc0eaea7a1cc Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Mon, 24 Oct 2022 15:28:32 +0200 Subject: [PATCH 4/4] feat(ls): provide OpenAPI 3.0.x Link lint rules Refs #2033 --- packages/apidom-ls/src/config/codes.ts | 6 +++++ .../openapi/link/lint/allowed-fields-3-0.ts | 23 +++++++++++++++++++ .../openapi/link/lint/description--type.ts | 16 +++++++++++++ .../src/config/openapi/link/lint/index.ts | 15 ++++++++++++ .../openapi/link/lint/operation-id--type.ts | 16 +++++++++++++ .../link/lint/operation-ref--format-uri.ts | 15 ++++++++++++ .../config/openapi/link/lint/server--type.ts | 16 +++++++++++++ .../apidom-ls/src/config/openapi/link/meta.ts | 2 ++ .../security-scheme/lint/scheme--required.ts | 2 +- 9 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/allowed-fields-3-0.ts create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/description--type.ts create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/index.ts create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/operation-id--type.ts create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/operation-ref--format-uri.ts create mode 100644 packages/apidom-ls/src/config/openapi/link/lint/server--type.ts diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index 94275484e..de27b4371 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -787,6 +787,12 @@ enum ApilintCodes { OPENAPI3_0_REFERENCE_FIELD_$REF_FORMAT_URI = 5260100, OPENAPI3_0_REFERENCE_FIELD_$REF_NO_SIBLINGS, + OPENAPI3_0_LINK = 5270000, + OPENAPI3_0_LINK_FIELD_OPERATION_REF_FORMAT_URI = 5270100, + OPENAPI3_0_LINK_FIELD_OPERATION_ID_TYPE = 5270200, + OPENAPI3_0_LINK_FIELD_DESCRIPTION_TYPE = 5270300, + OPENAPI3_0_LINK_FIELD_SERVER_TYPE = 5270400, + OPENAPI3_1 = 7000000, OPENAPI3_1_OPENAPI_VALUE_PATTERN_3_1_0 = 7000100, diff --git a/packages/apidom-ls/src/config/openapi/link/lint/allowed-fields-3-0.ts b/packages/apidom-ls/src/config/openapi/link/lint/allowed-fields-3-0.ts new file mode 100644 index 000000000..9b82b8f90 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/allowed-fields-3-0.ts @@ -0,0 +1,23 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +// eslint-disable-next-line @typescript-eslint/naming-convention +const allowedFields3_0Lint: LinterMeta = { + code: ApilintCodes.NOT_ALLOWED_FIELDS, + source: 'apilint', + message: 'Object includes not allowed fields', + severity: 1, + linterFunction: 'allowedFields', + linterParams: [ + ['operationRef', 'operationId', 'parameters', 'requestBody', 'description', 'server', '$ref'], + 'x-', + ], + marker: 'key', + 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 allowedFields3_0Lint; diff --git a/packages/apidom-ls/src/config/openapi/link/lint/description--type.ts b/packages/apidom-ls/src/config/openapi/link/lint/description--type.ts new file mode 100644 index 000000000..be1353e1b --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/description--type.ts @@ -0,0 +1,16 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const descriptionTypeLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_LINK_FIELD_DESCRIPTION_TYPE, + source: 'apilint', + message: 'description must be a string', + severity: 1, + linterFunction: 'apilintType', + linterParams: ['string'], + marker: 'value', + target: 'description', + data: {}, +}; + +export default descriptionTypeLint; diff --git a/packages/apidom-ls/src/config/openapi/link/lint/index.ts b/packages/apidom-ls/src/config/openapi/link/lint/index.ts new file mode 100644 index 000000000..06962530f --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/index.ts @@ -0,0 +1,15 @@ +import allowedFields3_0Lint from './allowed-fields-3-0'; +import operationRefFormatUriLink from './operation-ref--format-uri'; +import operationIdTypeLint from './operation-id--type'; +import descriptionTypeLint from './description--type'; +import serverTypeLint from './server--type'; + +const links = [ + operationRefFormatUriLink, + operationIdTypeLint, + descriptionTypeLint, + serverTypeLint, + allowedFields3_0Lint, +]; + +export default links; diff --git a/packages/apidom-ls/src/config/openapi/link/lint/operation-id--type.ts b/packages/apidom-ls/src/config/openapi/link/lint/operation-id--type.ts new file mode 100644 index 000000000..cc885a508 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/operation-id--type.ts @@ -0,0 +1,16 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const operationIdTypeLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_LINK_FIELD_OPERATION_ID_TYPE, + source: 'apilint', + message: "operationId' value must be a string", + severity: 1, + linterFunction: 'apilintType', + linterParams: ['string'], + marker: 'value', + target: 'operationId', + data: {}, +}; + +export default operationIdTypeLint; diff --git a/packages/apidom-ls/src/config/openapi/link/lint/operation-ref--format-uri.ts b/packages/apidom-ls/src/config/openapi/link/lint/operation-ref--format-uri.ts new file mode 100644 index 000000000..b50697d42 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/operation-ref--format-uri.ts @@ -0,0 +1,15 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const operationRefFormatURILint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_LINK_FIELD_OPERATION_REF_FORMAT_URI, + source: 'apilint', + message: "'operationRef' value must be a valid URI-reference", + severity: 1, + linterFunction: 'apilintValidURI', + marker: 'value', + target: 'operationRef', + data: {}, +}; + +export default operationRefFormatURILint; diff --git a/packages/apidom-ls/src/config/openapi/link/lint/server--type.ts b/packages/apidom-ls/src/config/openapi/link/lint/server--type.ts new file mode 100644 index 000000000..f674e47a3 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/link/lint/server--type.ts @@ -0,0 +1,16 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const serverTypeLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_LINK_FIELD_SERVER_TYPE, + source: 'apilint', + message: 'server must be an object', + severity: 1, + linterFunction: 'apilintElementOrClass', + linterParams: ['server'], + marker: 'value', + target: 'server', + data: {}, +}; + +export default serverTypeLint; diff --git a/packages/apidom-ls/src/config/openapi/link/meta.ts b/packages/apidom-ls/src/config/openapi/link/meta.ts index 7ad2bb2ca..381bda653 100644 --- a/packages/apidom-ls/src/config/openapi/link/meta.ts +++ b/packages/apidom-ls/src/config/openapi/link/meta.ts @@ -1,8 +1,10 @@ +import lint from './lint'; import completion from './completion'; import documentation from './documentation'; import { FormatMeta } from '../../../apidom-language-types'; const meta: FormatMeta = { + lint, completion, documentation, }; diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--required.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--required.ts index 4a0039e3b..5c1381432 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--required.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--required.ts @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes'; import { LinterMeta } from '../../../../apidom-language-types'; const schemeRequiredLint: LinterMeta = { - code: ApilintCodes.OPENAPI3_SECURITY_SCHEME_FIELD_SCHEME_REQUIRED, + code: ApilintCodes.OPENAPI3_0_SECURITY_SCHEME_FIELD_SCHEME_REQUIRED, source: 'apilint', message: "should always have a 'scheme'", severity: 1,