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
4 changes: 4 additions & 0 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ enum ApilintCodes {
OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_VALUES_TYPE = 5151000,
OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE,
OPENAPI3_0_PARAMETER_FIELD_CONTENT_VALUES_TYPE = 5151100,
OPENAPI3_0_PARAMETER_FIELD_CONTENT_ALLOWED_FIELDS,

OPENAPI3_0_REQUEST_BODY = 5160000,
OPENAPI3_0_REQUEST_BODY_FIELD_DESCRIPTION_TYPE = 5160200,
Expand Down Expand Up @@ -893,6 +894,9 @@ enum ApilintCodes {
OPENAPI3_1_SERVER_VARIABLE = 7060000,
OPENAPI3_1_SERVER_VARIABLE_FIELD_ENUM_TYPE = 7060100,

OPENAPI3_1_PARAMETER = 7070000,
OPENAPI3_1_PARAMETER_FIELD_CONTENT_ALLOWED_FIELDS = 7070100,

ADS = 8000000,

ADS_INFO = 8010000,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

// eslint-disable-next-line @typescript-eslint/naming-convention
const contentAllowedFields3_0Lint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_PARAMETER_FIELD_CONTENT_ALLOWED_FIELDS,
source: 'apilint',
message:
'If "content" field is present, following fields are not allowed: style, explode, allowReserved, example and examples',
severity: DiagnosticSeverity.Error,
linterFunction: 'allowedFields',
linterParams: [
[
'name',
'in',
'description',
'required',
'deprecated',
'allowEmptyValue',
'schema',
'content',
'$ref',
],
'x-',
],
marker: 'key',
conditions: [
{
function: 'existFields',
params: [['content']],
},
],
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 contentAllowedFields3_0Lint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

// eslint-disable-next-line @typescript-eslint/naming-convention
const contentAllowedFields3_1Lint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_PARAMETER_FIELD_CONTENT_ALLOWED_FIELDS,
source: 'apilint',
message:
'If "content" field is present, following fields are not allowed: style, explode, allowReserved, example and examples',
severity: DiagnosticSeverity.Error,
linterFunction: 'allowedFields',
linterParams: [
['name', 'in', 'description', 'required', 'deprecated', 'allowEmptyValue', 'schema', 'content'],
'x-',
],
marker: 'key',
conditions: [
{
function: 'existFields',
params: [['content']],
},
{
function: 'missingField',
params: ['$ref'],
},
],
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
};

export default contentAllowedFields3_1Lint;
4 changes: 4 additions & 0 deletions packages/apidom-ls/src/config/openapi/parameter/lint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import schemaMutuallyExclusiveLint from './schema--mutually-exclusive';
import examplesValuesTypeLint from './examples--values-type';
import examplesMutuallyExclusiveLint from './examples--mutually-exclusive';
import contentValuesTypeLint from './content--values-type';
import contentAllowedFields3_0Lint from './content--allowed-fields-3-0';
import contentAllowedFields3_1Lint from './content--allowed-fields-3-1';

const lints = [
nameTypeLint,
Expand All @@ -39,6 +41,8 @@ const lints = [
examplesValuesTypeLint,
examplesMutuallyExclusiveLint,
contentValuesTypeLint,
contentAllowedFields3_0Lint,
contentAllowedFields3_1Lint,
requiredFieldsLint,
allowedFields3_0Lint,
allowedFields3_1Lint,
Expand Down