Skip to content

Commit dac2698

Browse files
style(ls): apply code formatting and cleanup imports
- Remove unused OpenAPI32 import from schema completion - Fix string formatting in server completion - Apply consistent code formatting across OpenAPI 3.2 test files - Simplify multi-line assertions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 4a5a144 commit dac2698

File tree

6 files changed

+24
-64
lines changed

6 files changed

+24
-64
lines changed

packages/apidom-ls/src/config/openapi/schema/completion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import jsonSchema202012completion from '../../json-schema/2020-12/json-schema/completion.ts';
22
import { compose, assoc } from '../../json-schema/2020-12/target-specs.ts';
33
import commonSchemaCompletion from '../../common/schema/completion.ts';
4-
import { OpenAPI31, OpenAPI32 } from '../target-specs.ts';
4+
import { OpenAPI31 } from '../target-specs.ts';
55
import { ApidomCompletionItem } from '../../../apidom-language-types.ts';
66

77
const completion: ApidomCompletionItem[] = [

packages/apidom-ls/src/config/openapi/server/completion.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ const completion: ApidomCompletionItem[] = [
7171
insertTextFormat: 2,
7272
documentation: {
7373
kind: 'markdown',
74-
value:
75-
'A short name for the server.',
74+
value: 'A short name for the server.',
7675
},
7776
targetSpecs: OpenAPI32,
7877
},

packages/apidom-ls/test/openapi-3-2-completion.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ describe('OpenAPI 3.2.0 Completion', function () {
6868
? queryCompletion.documentation.value
6969
: '';
7070

71-
assert.include(
72-
queryDoc,
73-
'QUERY',
74-
'Documentation should mention QUERY method',
75-
);
71+
assert.include(queryDoc, 'QUERY', 'Documentation should mention QUERY method');
7672
});
7773

7874
it('should suggest additionalOperations in PathItem', async function () {
@@ -116,11 +112,7 @@ describe('OpenAPI 3.2.0 Completion', function () {
116112
? additionalOperationsCompletion.documentation.value
117113
: '';
118114

119-
assert.include(
120-
additionalOpsDoc,
121-
'HTTP methods',
122-
'Documentation should mention HTTP methods',
123-
);
115+
assert.include(additionalOpsDoc, 'HTTP methods', 'Documentation should mention HTTP methods');
124116
});
125117

126118
it('should not suggest query and additionalOperations for OpenAPI 3.1.0', async function () {
@@ -152,10 +144,7 @@ describe('OpenAPI 3.2.0 Completion', function () {
152144
(item) => item.label === 'additionalOperations',
153145
);
154146

155-
assert.isUndefined(
156-
queryCompletion,
157-
'Should NOT suggest "query" operation for 3.1.0',
158-
);
147+
assert.isUndefined(queryCompletion, 'Should NOT suggest "query" operation for 3.1.0');
159148
assert.isUndefined(
160149
additionalOperationsCompletion,
161150
'Should NOT suggest "additionalOperations" for 3.1.0',
@@ -186,9 +175,7 @@ describe('OpenAPI 3.2.0 Completion', function () {
186175

187176
const result = await languageService.doCompletion(doc, position, completionContext);
188177

189-
const mediaTypesCompletion = result?.items.find(
190-
(item) => item.label === 'mediaTypes',
191-
);
178+
const mediaTypesCompletion = result?.items.find((item) => item.label === 'mediaTypes');
192179

193180
assert.isDefined(mediaTypesCompletion, 'Should suggest "mediaTypes" field');
194181

@@ -228,14 +215,9 @@ describe('OpenAPI 3.2.0 Completion', function () {
228215

229216
const result = await languageService.doCompletion(doc, position, completionContext);
230217

231-
const mediaTypesCompletion = result?.items.find(
232-
(item) => item.label === 'mediaTypes',
233-
);
218+
const mediaTypesCompletion = result?.items.find((item) => item.label === 'mediaTypes');
234219

235-
assert.isUndefined(
236-
mediaTypesCompletion,
237-
'Should NOT suggest "mediaTypes" for 3.1.0',
238-
);
220+
assert.isUndefined(mediaTypesCompletion, 'Should NOT suggest "mediaTypes" for 3.1.0');
239221
});
240222
});
241223

@@ -361,9 +343,7 @@ components:
361343

362344
const result = await languageService.doCompletion(doc, position, completionContext);
363345

364-
const mediaTypesCompletion = result?.items.find(
365-
(item) => item.label === 'mediaTypes',
366-
);
346+
const mediaTypesCompletion = result?.items.find((item) => item.label === 'mediaTypes');
367347

368348
assert.isDefined(mediaTypesCompletion, 'Should suggest "mediaTypes" in YAML');
369349
});

packages/apidom-ls/test/openapi-3-2-documentation.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ describe('OpenAPI 3.2.0 Documentation/Hover', function () {
154154
: '';
155155

156156
// Check that documentation is present (specifics may vary)
157-
assert.isTrue(
158-
hoverText.length > 0,
159-
'Hover documentation should not be empty',
160-
);
157+
assert.isTrue(hoverText.length > 0, 'Hover documentation should not be empty');
161158
});
162159
});
163160

packages/apidom-ls/test/openapi-3-2-new-features.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
6060

6161
// Filter for query-related errors
6262
const queryErrors = result.filter(
63-
(d) =>
64-
d.message.includes('query') && d.severity === DiagnosticSeverity.Error,
63+
(d) => d.message.includes('query') && d.severity === DiagnosticSeverity.Error,
6564
);
6665

6766
assert.strictEqual(
@@ -123,8 +122,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
123122
// Filter for additionalOperations-related errors
124123
const additionalOpsErrors = result.filter(
125124
(d) =>
126-
d.message.includes('additionalOperations') &&
127-
d.severity === DiagnosticSeverity.Error,
125+
d.message.includes('additionalOperations') && d.severity === DiagnosticSeverity.Error,
128126
);
129127

130128
assert.strictEqual(
@@ -199,8 +197,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
199197
// Check for additionalOperations values error
200198
const additionalOpsValuesErrors = result.filter(
201199
(d) =>
202-
(d.message.includes('additionalOperations') ||
203-
d.message.includes('Operation')) &&
200+
(d.message.includes('additionalOperations') || d.message.includes('Operation')) &&
204201
d.severity === DiagnosticSeverity.Error,
205202
);
206203

@@ -231,8 +228,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
231228

232229
// Filter for querystring parameter errors
233230
const querystringErrors = result.filter(
234-
(d) =>
235-
d.message.includes('querystring') && d.severity === DiagnosticSeverity.Error,
231+
(d) => d.message.includes('querystring') && d.severity === DiagnosticSeverity.Error,
236232
);
237233

238234
assert.strictEqual(
@@ -266,11 +262,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
266262
d.severity === DiagnosticSeverity.Error,
267263
);
268264

269-
assert.isAtLeast(
270-
locationErrors.length,
271-
1,
272-
'Expected error for invalid parameter location',
273-
);
265+
assert.isAtLeast(locationErrors.length, 1, 'Expected error for invalid parameter location');
274266
});
275267

276268
it('should accept all valid parameter locations including querystring', async function () {
@@ -378,8 +370,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
378370

379371
// Filter for mediaTypes-related errors
380372
const mediaTypesErrors = result.filter(
381-
(d) =>
382-
d.message.includes('mediaTypes') && d.severity === DiagnosticSeverity.Error,
373+
(d) => d.message.includes('mediaTypes') && d.severity === DiagnosticSeverity.Error,
383374
);
384375

385376
assert.strictEqual(
@@ -407,9 +398,7 @@ describe('OpenAPI 3.2.0 New Features', function () {
407398

408399
// Check for mediaTypes type error
409400
const mediaTypesTypeErrors = result.filter(
410-
(d) =>
411-
d.message.includes('mediaTypes') &&
412-
d.severity === DiagnosticSeverity.Error,
401+
(d) => d.message.includes('mediaTypes') && d.severity === DiagnosticSeverity.Error,
413402
);
414403

415404
assert.isAtLeast(
@@ -470,16 +459,10 @@ describe('OpenAPI 3.2.0 New Features', function () {
470459

471460
// Check for "not allowed fields" errors
472461
const notAllowedErrors = result.filter(
473-
(d) =>
474-
d.message.includes('not allowed fields') &&
475-
d.severity === DiagnosticSeverity.Error,
462+
(d) => d.message.includes('not allowed fields') && d.severity === DiagnosticSeverity.Error,
476463
);
477464

478-
assert.isAtLeast(
479-
notAllowedErrors.length,
480-
1,
481-
'Expected error for invalid fields in PathItem',
482-
);
465+
assert.isAtLeast(notAllowedErrors.length, 1, 'Expected error for invalid fields in PathItem');
483466
});
484467
});
485468

packages/apidom-ls/test/validate.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6515,11 +6515,12 @@ describe('apidom-ls-validate', function () {
65156515
// The components object has an invalid field 'invalidField'
65166516
// The lint rule produces a diagnostic for fields that are not in the allowed list
65176517
const invalidFieldErrors = result.filter(
6518-
(d) =>
6519-
d.source === 'apilint' &&
6520-
d.message.includes('not allowed'),
6518+
(d) => d.source === 'apilint' && d.message.includes('not allowed'),
6519+
);
6520+
assert.isTrue(
6521+
invalidFieldErrors.length > 0,
6522+
'Should detect not allowed fields in components object',
65216523
);
6522-
assert.isTrue(invalidFieldErrors.length > 0, 'Should detect not allowed fields in components object');
65236524

65246525
languageService.terminate();
65256526
});

0 commit comments

Comments
 (0)