Skip to content

Commit 2dd5add

Browse files
committed
fix(ls): fix required lints in OpenAPI
Required lints are now performed only when field is missing. Refs #2264 Refs swagger-api/swagger-editor#3652
1 parent d8aa73a commit 2dd5add

File tree

9 files changed

+36
-4
lines changed

9 files changed

+36
-4
lines changed

packages/apidom-ls/src/config/openapi/operation/lint/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import parametersTypeLint from './parameters--type';
99
import parametersItemsTypeLint from './parameters--items-type';
1010
import requestBodyTypeLint from './request-body--type';
1111
import responsesTypeLint from './responses--type';
12-
import responsesRequiredLint3_0 from './responses-3-0--required';
12+
import responsesRequired3_0Lint from './responses-3-0--required';
1313
import callbacksValuesTypeLint from './callbacks--values-type';
1414
import deprecatedTypeLint from './deprecated--type';
1515
import securityTypeLint from './security--type';
@@ -28,7 +28,7 @@ const lints = [
2828
parametersItemsTypeLint,
2929
requestBodyTypeLint,
3030
responsesTypeLint,
31-
responsesRequiredLint3_0,
31+
responsesRequired3_0Lint,
3232
callbacksValuesTypeLint,
3333
deprecatedTypeLint,
3434
securityTypeLint,

packages/apidom-ls/src/config/openapi/operation/lint/responses-3-0--required.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes';
22
import { LinterMeta } from '../../../../apidom-language-types';
33

44
// eslint-disable-next-line @typescript-eslint/naming-convention
5-
const responsesRequiredLint3_0: LinterMeta = {
5+
const responsesRequired3_0Lint: LinterMeta = {
66
code: ApilintCodes.OPENAPI3_0_OPERATION_FIELD_RESPONSES_REQUIRED,
77
source: 'apilint',
88
message: "should always have a 'responses'",
@@ -28,4 +28,4 @@ const responsesRequiredLint3_0: LinterMeta = {
2828
],
2929
};
3030

31-
export default responsesRequiredLint3_0;
31+
export default responsesRequired3_0Lint;

packages/apidom-ls/src/config/openapi/parameter/lint/required--required.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const requiredRequiredLint: LinterMeta = {
1515
function: 'apilintContainsValue',
1616
params: ['path'],
1717
},
18+
{
19+
function: 'missingField',
20+
params: ['$ref'],
21+
},
1822
],
1923
data: {
2024
quickFix: [

packages/apidom-ls/src/config/openapi/request-body/lint/content--required.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const requiredRequiredLint: LinterMeta = {
1919
},
2020
],
2121
},
22+
conditions: [
23+
{
24+
function: 'missingField',
25+
params: ['$ref'],
26+
},
27+
],
2228
};
2329

2430
export default requiredRequiredLint;

packages/apidom-ls/src/config/openapi/response/lint/description--required.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const descriptionRequiredLint: LinterMeta = {
1919
},
2020
],
2121
},
22+
conditions: [
23+
{
24+
function: 'missingField',
25+
params: ['$ref'],
26+
},
27+
],
2228
};
2329

2430
export default descriptionRequiredLint;

packages/apidom-ls/src/config/openapi/security-scheme/lint/flows--required.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const flowsRequiredLint: LinterMeta = {
2525
function: 'apilintContainsValue',
2626
params: ['oauth2'],
2727
},
28+
{
29+
function: 'missingField',
30+
params: ['$ref'],
31+
},
2832
],
2933
};
3034

packages/apidom-ls/src/config/openapi/security-scheme/lint/name--required.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const nameRequiredLint: LinterMeta = {
2525
function: 'apilintContainsValue',
2626
params: ['apiKey'],
2727
},
28+
{
29+
function: 'missingField',
30+
params: ['$ref'],
31+
},
2832
],
2933
};
3034

packages/apidom-ls/src/config/openapi/security-scheme/lint/open-id-connect-url--required.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const openIdConnectUrlRequiredLint: LinterMeta = {
2525
function: 'apilintContainsValue',
2626
params: ['openIdConnect'],
2727
},
28+
{
29+
function: 'missingField',
30+
params: ['$ref'],
31+
},
2832
],
2933
};
3034

packages/apidom-ls/src/config/openapi/security-scheme/lint/scheme--required.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const schemeRequiredLint: LinterMeta = {
2525
function: 'apilintContainsValue',
2626
params: ['http'],
2727
},
28+
{
29+
function: 'missingField',
30+
params: ['$ref'],
31+
},
2832
],
2933
};
3034

0 commit comments

Comments
 (0)