Skip to content

Commit

Permalink
fix(ls): finalize rules for OpenAPI License object
Browse files Browse the repository at this point in the history
Refs 20a09d5
  • Loading branch information
char0n committed Oct 19, 2022
1 parent be8a96a commit adb48bf
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
5 changes: 3 additions & 2 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,9 @@ enum ApilintCodes {
OPENAPI3_1_COMPONENTS = 7020000,
OPENAPI3_1_COMPONENTS_FIELD_PATH_ITEMS_VALUES_TYPE = 7020100,

OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE = 7040300,
OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_MUTUALLY_EXCLUSIVE = 7040600,
OPENAPI3_1_LICENSE = 7030000,
OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE = 7030100,
OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_MUTUALLY_EXCLUSIVE,

ADS = 8000000,
ADS_INFO = 8010000,
Expand Down
13 changes: 0 additions & 13 deletions packages/apidom-ls/src/config/openapi/license/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ const completion: ApidomCompletionItem[] = [
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
{
label: 'email',
insertText: 'email',
kind: 14,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'The email address of the contact person/organization. This MUST be in the form of an email address.',
},
},
];

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

const identifierTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE,
source: 'apilint',
message: "'identifier' must be a string",
severity: 1,
linterFunction: 'apilintType',
linterParams: ['string'],
marker: 'value',
target: 'name',
data: {},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
};

export default identifierTypeLint;
2 changes: 2 additions & 0 deletions packages/apidom-ls/src/config/openapi/license/lint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import allowedFields3_0Lint from './allowed-fields-3-0';
import allowedFields3_1Lint from './allowed-fields-3-1';
import nameTypeLint from './name--type';
import nameRequiredLint from './name--required';
import identifierTypeLint from './identifier--type';
import identifierMutuallyExclusiveLint from './identifier--mutually-exclusive';
import urlFormatURILint from './url--format-uri';

const lints = [
nameTypeLint,
nameRequiredLint,
identifierTypeLint,
identifierMutuallyExclusiveLint,
urlFormatURILint,
allowedFields3_0Lint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

const nameTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE,
code: ApilintCodes.OPENAPI3_0_LICENSE_FIELD_NAME_TYPE,
source: 'apilint',
message: "'identifier' must be a string",
severity: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ls/test/openapi-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ describe('apidom-ls', function () {
source: 'apilint',
},
{
code: 7040600,
code: 7030101,
message: 'The identifier field and url field are mutually exclusive.',
range: {
end: {
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ls/test/openapi-yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ describe('apidom-ls-yaml', function () {
source: 'apilint',
},
{
code: 7040600,
code: 7030101,
message: 'The identifier field and url field are mutually exclusive.',
range: {
end: {
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-ls/test/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,7 @@ describe('apidom-ls-validate', function () {
const result = await languageService.doValidation(doc, validationContext);
const expected: Diagnostic[] = [
{
code: 7040600,
code: 7030101,
message: 'The identifier field and url field are mutually exclusive.',
range: {
end: {
Expand Down

0 comments on commit adb48bf

Please sign in to comment.