Skip to content

Commit 8dc4164

Browse files
author
Ansh Chaturvedi
committed
fix: add union type test to externalModuleApiSpec.test.ts
1 parent eae3632 commit 8dc4164

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,51 @@ testCase(
271271
},
272272
[],
273273
);
274+
275+
testCase(
276+
'simple api spec with exported union type',
277+
'test/sample-types/apiSpecWithUnion.ts',
278+
{
279+
openapi: "3.0.3",
280+
info: {
281+
title: "simple api spec with exported union type",
282+
version: "4.7.4",
283+
description: "simple api spec with exported union type"
284+
},
285+
paths: {
286+
"/test": {
287+
get: {
288+
parameters: [],
289+
responses: {
290+
200: {
291+
description: "OK",
292+
content: {
293+
'application/json': {
294+
schema: {
295+
$ref: "#/components/schemas/SampleUnion"
296+
}
297+
}
298+
}
299+
}
300+
}
301+
}
302+
}
303+
},
304+
components: {
305+
schemas: {
306+
SampleUnion: {
307+
title: "SampleUnion",
308+
oneOf: [
309+
{
310+
type: "string"
311+
},
312+
{
313+
type: "number"
314+
}
315+
]
316+
}
317+
}
318+
}
319+
},
320+
[]
321+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { SampleUnion } from '@bitgo/test-types';
2+
import * as h from '@api-ts/io-ts-http';
3+
4+
export const enumTest = h.apiSpec({
5+
'api.get.test': {
6+
get: h.httpRoute({
7+
path: '/test',
8+
method: 'GET',
9+
request: h.httpRequest({}),
10+
response: {
11+
200: SampleUnion,
12+
},
13+
}),
14+
},
15+
});

packages/openapi-generator/test/sample-types/node_modules/@bitgo/test-types/src/index.ts

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)