Skip to content

Commit 2365e36

Browse files
committed
test(openapi-generator): add new test with type descriptions
1 parent 26f18f1 commit 2365e36

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,3 +1333,112 @@ testCase('route with multiple unknown tags', ROUTE_WITH_MULTIPLE_UNKNOWN_TAGS, {
13331333
schemas: {},
13341334
},
13351335
});
1336+
1337+
1338+
const ROUTE_WITH_TYPE_DESCRIPTIONS = `
1339+
import * as t from 'io-ts';
1340+
import * as h from '@api-ts/io-ts-http';
1341+
1342+
/**
1343+
* A simple route with type descriptions
1344+
*
1345+
* @operationId api.v1.test
1346+
* @tag Test Routes
1347+
*/
1348+
export const route = h.httpRoute({
1349+
path: '/foo',
1350+
method: 'GET',
1351+
request: h.httpRequest({
1352+
body: {
1353+
/** foo description */
1354+
foo: t.string,
1355+
/** bar description */
1356+
bar: t.number,
1357+
child: {
1358+
/** child description */
1359+
child: t.string,
1360+
}
1361+
},
1362+
}),
1363+
response: {
1364+
200: {
1365+
test: t.string
1366+
}
1367+
},
1368+
});
1369+
`;
1370+
1371+
testCase('route with type descriptions', ROUTE_WITH_TYPE_DESCRIPTIONS, {
1372+
openapi: '3.0.3',
1373+
info: {
1374+
title: 'Test',
1375+
version: '1.0.0',
1376+
},
1377+
paths: {
1378+
'/foo': {
1379+
get: {
1380+
summary: 'A simple route with type descriptions',
1381+
operationId: 'api.v1.test',
1382+
tags: ['Test Routes'],
1383+
parameters: [],
1384+
requestBody: {
1385+
content: {
1386+
'application/json': {
1387+
schema: {
1388+
properties: {
1389+
bar: {
1390+
description: 'bar description',
1391+
type: 'number'
1392+
},
1393+
child: {
1394+
properties: {
1395+
child: {
1396+
description: 'child description',
1397+
type: 'string'
1398+
}
1399+
},
1400+
required: [
1401+
'child'
1402+
],
1403+
type: 'object'
1404+
},
1405+
foo: {
1406+
description: 'foo description',
1407+
type: 'string'
1408+
}
1409+
},
1410+
required: [
1411+
'foo',
1412+
'bar',
1413+
'child'
1414+
],
1415+
type: 'object'
1416+
}
1417+
}
1418+
}
1419+
},
1420+
responses: {
1421+
200: {
1422+
description: 'OK',
1423+
content: {
1424+
'application/json': {
1425+
schema: {
1426+
type: 'object',
1427+
properties: {
1428+
test: {
1429+
type: 'string',
1430+
},
1431+
},
1432+
required: ['test'],
1433+
},
1434+
},
1435+
},
1436+
},
1437+
},
1438+
},
1439+
},
1440+
},
1441+
components: {
1442+
schemas: {},
1443+
},
1444+
});

0 commit comments

Comments
 (0)