Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,6 +17,7 @@ import openIdConnectUrlRequiredLint from './open-id-connect-url--required';

const lints = [
typeEquals3_0Lint,
typeEquals3_1Lint,
descriptionTypeLint,
nameTypeLint,
nameRequiredLint,
Expand All @@ -28,6 +31,7 @@ const lints = [
openIdConnectUrlFormatURILint,
openIdConnectUrlRequiredLint,
allowedFields3_0Lint,
allowedFields3_1Lint,
];

export default lints;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
@@ -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;