Skip to content

Commit f4f39b7

Browse files
Merge pull request #1024 from ericcrosson-bitgo/style-format-openapi-generator-test-files
style: format openapi-generator test files
2 parents 822d533 + e0a8f44 commit f4f39b7

15 files changed

+1768
-1861
lines changed

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
coverage/
22
dist/
33
flake.lock
4-
packages/openapi-generator/test/

packages/openapi-generator/test/codec.test.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ export const FOO = t.union([t.string, t.number]);
220220
testCase('union type is parsed', UNION, {
221221
FOO: {
222222
type: 'union',
223-
schemas: [{ type: 'string', primitive: true }, { type: 'number', primitive: true }],
223+
schemas: [
224+
{ type: 'string', primitive: true },
225+
{ type: 'number', primitive: true },
226+
],
224227
},
225228
});
226229

@@ -235,7 +238,10 @@ export const FOO = t.union([...common, t.number]);
235238
testCase('union type with spread is parsed', UNION_SPREAD, {
236239
FOO: {
237240
type: 'union',
238-
schemas: [{ type: 'string', primitive: true }, { type: 'number', primitive: true }],
241+
schemas: [
242+
{ type: 'string', primitive: true },
243+
{ type: 'number', primitive: true },
244+
],
239245
},
240246
common: {
241247
type: 'tuple',
@@ -252,7 +258,10 @@ export const FOO = t.union([...[t.string], t.number]);
252258
testCase('union type with inline spread is parsed', UNION_INLINE_SPREAD, {
253259
FOO: {
254260
type: 'union',
255-
schemas: [{ type: 'string', primitive: true }, { type: 'number', primitive: true }],
261+
schemas: [
262+
{ type: 'string', primitive: true },
263+
{ type: 'number', primitive: true },
264+
],
256265
},
257266
});
258267

@@ -285,7 +294,11 @@ export const FOO = t.record(t.string, t.number);
285294
`;
286295

287296
testCase('record type is parsed', RECORD, {
288-
FOO: { type: 'record', domain: {type: 'string', primitive: true}, codomain: { type: 'number', primitive: true } },
297+
FOO: {
298+
type: 'record',
299+
domain: { type: 'string', primitive: true },
300+
codomain: { type: 'number', primitive: true },
301+
},
289302
});
290303

291304
const ENUM = `

packages/openapi-generator/test/externalModule.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function testCase(
2828
for (const path of Object.keys(expected)) {
2929
const resolvedPath = p.resolve(path);
3030
const sourceFile = project.get(resolvedPath);
31-
31+
3232
if (sourceFile === undefined) {
3333
throw new Error(`Source file ${path} not found`);
3434
}

packages/openapi-generator/test/externalModuleApiSpec.test.ts

+74-69
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async function testCase(
103103
const codecE = parseCodecInitializer(project, newSourceFile, init);
104104
if (E.isLeft(codecE)) {
105105
errors.push(
106-
`Could not parse codec '${ref.name}' in '${ref.location}': ${codecE.left}`,
106+
`Could not parse codec '${ref.name}' in '${ref.location}': ${codecE.left}`,
107107
);
108108
break;
109109
}
@@ -117,15 +117,15 @@ async function testCase(
117117
const openapi = convertRoutesToOpenAPI(
118118
{
119119
title: name,
120-
version: "1.0.0",
120+
version: '1.0.0',
121121
description,
122122
},
123123
[],
124124
apiSpec,
125125
components,
126126
);
127127

128-
assert.deepStrictEqual(errors, expectedErrors);
128+
assert.deepStrictEqual(errors, expectedErrors);
129129
assert.deepStrictEqual(openapi, expected);
130130
});
131131
}
@@ -275,91 +275,96 @@ testCase(
275275
'simple api spec with exported union type',
276276
'test/sample-types/apiSpecWithUnion.ts',
277277
{
278-
openapi: "3.0.3",
278+
openapi: '3.0.3',
279279
info: {
280-
title: "simple api spec with exported union type",
281-
version: "1.0.0",
282-
description: "simple api spec with exported union type"
280+
title: 'simple api spec with exported union type',
281+
version: '1.0.0',
282+
description: 'simple api spec with exported union type',
283283
},
284284
paths: {
285-
"/test": {
285+
'/test': {
286286
get: {
287287
parameters: [],
288288
responses: {
289289
200: {
290-
description: "OK",
290+
description: 'OK',
291291
content: {
292292
'application/json': {
293293
schema: {
294-
$ref: "#/components/schemas/SampleUnion"
295-
}
296-
}
297-
}
298-
}
299-
}
300-
}
301-
}
294+
$ref: '#/components/schemas/SampleUnion',
295+
},
296+
},
297+
},
298+
},
299+
},
300+
},
301+
},
302302
},
303303
components: {
304304
schemas: {
305305
SampleUnion: {
306-
title: "SampleUnion",
306+
title: 'SampleUnion',
307307
oneOf: [
308308
{
309-
type: "string"
309+
type: 'string',
310310
},
311311
{
312-
type: "number"
313-
}
314-
]
315-
}
316-
}
317-
}
312+
type: 'number',
313+
},
314+
],
315+
},
316+
},
317+
},
318318
},
319-
[]
320-
)
319+
[],
320+
);
321321

322-
testCase("simple api spec with custom codec", "test/sample-types/apiSpecWithCustomCodec.ts", {
323-
openapi: "3.0.3",
324-
info: {
325-
title: "simple api spec with custom codec",
326-
version: "1.0.0",
327-
description: "simple api spec with custom codec"
328-
},
329-
paths: {
330-
"/test": {
331-
get: {
332-
parameters: [],
333-
responses: {
334-
200: {
335-
description: "OK",
336-
content: {
337-
'application/json': {
338-
schema: {
339-
type: 'string',
340-
description: 'Sample custom codec',
341-
example: 'sample',
342-
format: 'sample'
343-
}
344-
}
345-
}
322+
testCase(
323+
'simple api spec with custom codec',
324+
'test/sample-types/apiSpecWithCustomCodec.ts',
325+
{
326+
openapi: '3.0.3',
327+
info: {
328+
title: 'simple api spec with custom codec',
329+
version: '1.0.0',
330+
description: 'simple api spec with custom codec',
331+
},
332+
paths: {
333+
'/test': {
334+
get: {
335+
parameters: [],
336+
responses: {
337+
200: {
338+
description: 'OK',
339+
content: {
340+
'application/json': {
341+
schema: {
342+
type: 'string',
343+
description: 'Sample custom codec',
344+
example: 'sample',
345+
format: 'sample',
346+
},
347+
},
348+
},
349+
},
350+
201: {
351+
description: 'Created',
352+
content: {
353+
'application/json': {
354+
schema: {
355+
type: 'number',
356+
description: 'Another sample codec',
357+
},
358+
},
359+
},
360+
},
346361
},
347-
201: {
348-
description: 'Created',
349-
content: {
350-
'application/json': {
351-
schema: {
352-
type: 'number',
353-
description: 'Another sample codec',
354-
}
355-
}
356-
}
357-
}
358-
}
359-
}
360-
}
362+
},
363+
},
364+
},
365+
components: {
366+
schemas: {},
367+
},
361368
},
362-
components: {
363-
schemas: {}
364-
}
365-
}, []);
369+
[],
370+
);

0 commit comments

Comments
 (0)