Skip to content

Commit

Permalink
fix(ls): oas31 lint rules require oneOf paths, components, webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lai committed Oct 7, 2022
1 parent c599710 commit 6d2d7c3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 83 deletions.
1 change: 1 addition & 0 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ enum ApilintCodes {
OPENAPI3_1_OPENAPI_VALUE_PATTERN_3_1_0 = 7000100,

OPENAPI3_1_OPEN_API = 7010000,
OPENAPI3_1_OPEN_API_REQUIRED_FIELDS = 7010010,
OPENAPI3_1_OPEN_API_FIELD_INFO_TYPE = 7010100,
OPENAPI3_1_OPEN_API_FIELD_INFO_TYPE_REQUIRED,
OPENAPI3_1_OPEN_API_FIELD_SERVERS_TYPE = 7010200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const completion: ApidomCompletionItem[] = [
label: 'jsonSchemaDialect',
insertText: 'jsonSchemaDialect',
kind: 14,
format: CompletionFormat.UNQUOTED,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
import allowedFieldsLint from './allowed-fields';
import requiredFieldsLint from './required-fields';
import componentsTypeLint from './components--type';
import componentsRequiredLint from './components--required';
import externalDocsTypeLint from './external-docs--type';
import infoRequiredLint from './info--required';
import infoTypeLint from './info--type';
import jsonSchemaDialectFormatURILint from './jsonSchemaDialect--format-uri';
import pathsTypeLint from './paths--type';
import pathsRequiredLint from './paths--required';
import securityItemsTypeLint from './security--items-type';
import securityTypeLint from './security--type';
import serversItemsTypeLint from './servers--items-type';
import serversTypeLint from './servers--type';
import tagsItemsTypeLint from './tags--items-type';
import tagsTypeLint from './tags--type';
import webhooksLint from './webhooks--type';
import webhooksRequiredLint from './webhooks--required';

const lints = [
allowedFieldsLint,
requiredFieldsLint,
componentsTypeLint,
componentsRequiredLint,
externalDocsTypeLint,
infoRequiredLint,
infoTypeLint,
jsonSchemaDialectFormatURILint,
pathsTypeLint,
pathsRequiredLint,
securityItemsTypeLint,
securityTypeLint,
serversItemsTypeLint,
serversTypeLint,
tagsItemsTypeLint,
tagsTypeLint,
webhooksLint,
webhooksRequiredLint,
];

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

const pathsRequiredLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_OPEN_API_FIELD_PATHS_REQUIRED,
const requiredFieldsLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_OPEN_API_REQUIRED_FIELDS,
source: 'apilint',
message: "should always have a 'paths' section",
message: 'OpenAPI Object must contain one the following fields: paths, components, webhooks',
severity: 1,
linterFunction: 'hasRequiredField',
linterParams: ['paths'],
marker: 'key',
// conditions: [
// {
// // todo: fix setup so oas31 consists at least oneOf paths, components, webhooks
// targets: [{ path: 'openApi3_1' }],
// function: 'apilintContainsValue',
// params: ['paths'],
// },
// ],
conditions: [
{
targets: [{ path: 'root' }],
function: 'missingFields',
params: [['paths', 'components', 'webhooks']],
},
],
data: {
quickFix: [
{
Expand All @@ -29,4 +28,4 @@ const pathsRequiredLint: LinterMeta = {
},
};

export default pathsRequiredLint;
export default requiredFieldsLint;

This file was deleted.

0 comments on commit 6d2d7c3

Please sign in to comment.