diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index bd31e6e8f6..1c415e3274 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -848,6 +848,9 @@ enum ApilintCodes { OPENAPI3_1_REFERENCE = 7040000, OPENAPI3_1_REFERENCE_FIELD_$REF_ALLOWED_SIBLINGS = 7040100, + OPENAPI3_1_SECURITY_SCHEME = 7050000, + OPENAPI3_1_SECURITY_SCHEME_FIELD_TYPE_EQUALS = 7050100, + ADS = 8000000, ADS_INFO = 8010000, ADS_INFO_REQUIRED = 8010010, diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/completion.ts b/packages/apidom-ls/src/config/openapi/security-scheme/completion.ts index d2058d1961..e2eab550b7 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/completion.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/completion.ts @@ -36,6 +36,20 @@ const completion: ApidomCompletionItem[] = [ { namespace: 'openapi', version: '3.0.3' }, ], }, + { + label: 'type', + insertText: 'type', + kind: 14, + format: CompletionFormat.QUOTED, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + '**REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"mutualTLS"`, `"oauth2"`, `"openIdConnect"`.', + }, + targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], + }, { label: 'description', insertText: 'description', @@ -120,6 +134,20 @@ const completion: ApidomCompletionItem[] = [ { namespace: 'openapi', version: '3.0.3' }, ], }, + { + label: 'flows', + insertText: 'flows', + kind: 14, + format: CompletionFormat.OBJECT, + type: CompletionType.PROPERTY, + insertTextFormat: 2, + documentation: { + kind: 'markdown', + value: + '[OAuth Flows Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oauthFlowsObject)\n\\\nApplies to `oauth2`. **REQUIRED**. An object containing configuration information for the flow types supported.', + }, + targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], + }, { label: 'openIdConnectUrl', insertText: 'openIdConnectUrl', diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/allowed-fields-3-1.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/allowed-fields-3-1.ts new file mode 100644 index 0000000000..22b86b178c --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/allowed-fields-3-1.ts @@ -0,0 +1,25 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +// eslint-disable-next-line @typescript-eslint/naming-convention +const allowedFields3_1Lint: LinterMeta = { + code: ApilintCodes.NOT_ALLOWED_FIELDS, + source: 'apilint', + message: 'Object includes not allowed fields', + severity: 1, + linterFunction: 'allowedFields', + linterParams: [ + ['type', 'description', 'name', 'in', 'scheme', 'bearerFormat', 'flows', 'openIdConnectUrl'], + 'x-', + ], + marker: 'key', + conditions: [ + { + function: 'missingField', + params: ['$ref'], + }, + ], + targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], +}; + +export default allowedFields3_1Lint; diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/index.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/index.ts index 2266219c12..1f1097da60 100644 --- a/packages/apidom-ls/src/config/openapi/security-scheme/lint/index.ts +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/index.ts @@ -1,5 +1,7 @@ import allowedFields3_0Lint from './allowed-fields-3-0'; +import allowedFields3_1Lint from './allowed-fields-3-1'; import typeEquals3_0Lint from './type--equals-3-0'; +import typeEquals3_1Lint from './type--equals-3-1'; import descriptionTypeLint from './description--type'; import nameTypeLint from './name--type'; import nameRequiredLint from './name--required'; @@ -15,6 +17,7 @@ import openIdConnectUrlRequiredLint from './open-id-connect-url--required'; const lints = [ typeEquals3_0Lint, + typeEquals3_1Lint, descriptionTypeLint, nameTypeLint, nameRequiredLint, @@ -28,6 +31,7 @@ const lints = [ openIdConnectUrlFormatURILint, openIdConnectUrlRequiredLint, allowedFields3_0Lint, + allowedFields3_1Lint, ]; export default lints; 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 b93d06cbbf..99b1034670 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 @@ -11,6 +11,12 @@ const typeEquals3_0Lint: LinterMeta = { linterParams: [['apiKey', 'http', 'oauth2', 'openIdConnect']], marker: 'value', target: 'type', + 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 typeEquals3_0Lint; diff --git a/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-1.ts b/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-1.ts new file mode 100644 index 0000000000..f133b0a193 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/security-scheme/lint/type--equals-3-1.ts @@ -0,0 +1,17 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +// eslint-disable-next-line @typescript-eslint/naming-convention +const typeEquals3_1Lint: LinterMeta = { + code: ApilintCodes.OPENAPI3_1_SECURITY_SCHEME_FIELD_TYPE_EQUALS, + source: 'apilint', + message: 'type must be one of allowed values', + severity: 1, + linterFunction: 'apilintValueOrArray', + linterParams: [['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect']], + marker: 'value', + target: 'type', + targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }], +}; + +export default typeEquals3_1Lint;