Skip to content

feat(ls): provide OpenAPI 3.0.x Reference lint rules #2185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2022
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

This file was deleted.

15 changes: 0 additions & 15 deletions packages/apidom-ls/src/config/openapi/example/lint/$ref--valid.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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: [['summary', 'description', 'value', 'externalValue', '$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;

This file was deleted.

8 changes: 2 additions & 6 deletions packages/apidom-ls/src/config/openapi/example/lint/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import allowedFieldsLint from './allowed-fields';
import $refValidLint from './$ref--valid';
import $refNoSiblingsLint from './$ref--no-siblings';
import allowedFields3_0Lint from './allowed-fields-3-0';
import summaryTypeLint from './summary--type';
import descriptionTypeLint from './description--type';
import valueMutuallyExclusiveLint from './value--mutually-exclusive';
Expand All @@ -11,9 +9,7 @@ const lints = [
descriptionTypeLint,
valueMutuallyExclusiveLint,
externalValueFormatURILint,
$refValidLint,
$refNoSiblingsLint,
allowedFieldsLint,
allowedFields3_0Lint,
];

export default lints;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

const allowedFieldsLint: LinterMeta = {
// 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: [['description', 'content', 'required', '$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 allowedFieldsLint;
export default allowedFields3_0Lint;
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import allowedFieldsLint from './allowed-fields';
import $refNoSiblingsLint from './$ref--no-siblings';
import $refValidLint from './$ref--valid';
import allowedFields3_0Lint from './allowed-fields-3-0';
import descriptionTypeLint from './description--type';
import contentValuesTypeLint from './content--values-type';
import contentRequiredLint from './content--required';
import requiredTypeLint from './required--type';

const lints = [
allowedFieldsLint,
$refNoSiblingsLint,
$refValidLint,
descriptionTypeLint,
contentRequiredLint,
contentValuesTypeLint,
requiredTypeLint,
allowedFields3_0Lint,
];

export default lints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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: [['description', 'headers', 'content', 'links', '$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;

This file was deleted.

4 changes: 2 additions & 2 deletions packages/apidom-ls/src/config/openapi/response/lint/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import allowedFieldsLint from './allowed-fields';
import allowedFields3_0Lint from './allowed-fields-3-0';
import descriptionTypeLint from './description--type';
import descriptionRequiredLint from './description--required';
import headersValuesTypeLint from './headers--values-type';
Expand All @@ -11,7 +11,7 @@ const lints = [
headersValuesTypeLint,
contentValuesTypeLint,
linksValuesTypeLint,
allowedFieldsLint,
allowedFields3_0Lint,
];

export default lints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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: [
[
'type',
'description',
'name',
'in',
'scheme',
'bearerFormat',
'flows',
'openIdConnectUrl',
'$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;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import allowedFieldsLint from './allowed-fields';
import allowedFields3_0Lint from './allowed-fields-3-0';
import typeEquals3_0Lint from './type--equals-3-0';
import descriptionTypeLint from './description--type';
import nameTypeLint from './name--type';
Expand Down Expand Up @@ -27,7 +27,7 @@ const lints = [
flowsRequiredLint,
openIdConnectUrlFormatURILint,
openIdConnectUrlRequiredLint,
allowedFieldsLint,
allowedFields3_0Lint,
];

export default lints;