Skip to content

Commit de77726

Browse files
committed
feat(ls): oas31 lint add info object required
1 parent f51e895 commit de77726

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

packages/apidom-ls/src/config/codes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ enum ApilintCodes {
698698
OPENAPI3_1_OPEN_API = 7010000,
699699
OPENAPI3_1_OPEN_API_FIELD_WEBHOOKS_TYPE = 7010100,
700700
OPENAPI3_1_OPEN_API_FIELD_JSON_SCHEMA_DIALECT_TYPE = 7010200,
701+
OPENAPI3_1_OPEN_API_FIELD_INFO_TYPE = 7010300,
701702
OPENAPI3_1_OPEN_API_FIELD_INFO_TYPE_REQUIRED,
702703

703704
OPENAPI3_1_INFO = 7020000,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import allowedFieldsLint from './allowed-fields';
2+
import infoRequiredLint from './info--required';
23
import jsonSchemaDialectTypeLint from './jsonSchemaDialect--type';
34
import webhooksLint from './webhooks--type';
45

5-
const lints = [allowedFieldsLint, jsonSchemaDialectTypeLint, webhooksLint];
6+
const lints = [allowedFieldsLint, infoRequiredLint, jsonSchemaDialectTypeLint, webhooksLint];
67

78
export default lints;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ApilintCodes from '../../../codes';
2+
import { LinterMeta } from '../../../../apidom-language-types';
3+
4+
const infoRequiredLint: LinterMeta = {
5+
code: ApilintCodes.OPENAPI3_1_OPEN_API_FIELD_INFO_TYPE_REQUIRED,
6+
source: 'apilint',
7+
message: "should always have a 'info' section",
8+
severity: 1,
9+
linterFunction: 'hasRequiredField',
10+
linterParams: ['info'],
11+
marker: 'key',
12+
data: {
13+
quickFix: [
14+
{
15+
message: "add 'info' section",
16+
action: 'addChild',
17+
snippetYaml: 'info: \n \n',
18+
snippetJson: '"info": {\n \n },\n',
19+
},
20+
],
21+
},
22+
};
23+
24+
export default infoRequiredLint;

0 commit comments

Comments
 (0)