File tree Expand file tree Collapse file tree 2 files changed +129
-1
lines changed
packages/openapi-generator Expand file tree Collapse file tree 2 files changed +129
-1
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ export function schemaToOpenAPI(
234234 case 'undefined' :
235235 return undefined ;
236236 case 'any' :
237- return { } ;
237+ return { ... defaultOpenAPIObject } ;
238238 default :
239239 return { } ;
240240 }
Original file line number Diff line number Diff line change @@ -1232,3 +1232,131 @@ testCase(
12321232 } ,
12331233 } ,
12341234) ;
1235+
1236+ const ROUTE_WITH_ANY_AND_DESCRIPTION = `
1237+ import * as t from 'io-ts';
1238+ import * as h from '@api-ts/io-ts-http';
1239+
1240+ /**
1241+ * A simple route
1242+ *
1243+ * @operationId api.v1.test
1244+ * @tag Test Routes
1245+ */
1246+ export const route = h.httpRoute({
1247+ path: '/foo',
1248+ method: 'GET',
1249+ request: h.httpRequest({}),
1250+ response: {
1251+ 200: {
1252+ /**
1253+ * Test description
1254+ */
1255+ test: t.any
1256+ }
1257+ },
1258+ });
1259+ ` ;
1260+
1261+ testCase ( 'route with example object' , ROUTE_WITH_ANY_AND_DESCRIPTION , {
1262+ openapi : '3.0.3' ,
1263+ info : {
1264+ title : 'Test' ,
1265+ version : '1.0.0' ,
1266+ } ,
1267+ paths : {
1268+ '/foo' : {
1269+ get : {
1270+ summary : 'A simple route' ,
1271+ operationId : 'api.v1.test' ,
1272+ tags : [ 'Test Routes' ] ,
1273+ parameters : [ ] ,
1274+ responses : {
1275+ 200 : {
1276+ description : 'OK' ,
1277+ content : {
1278+ 'application/json' : {
1279+ schema : {
1280+ type : 'object' ,
1281+ properties : {
1282+ test : {
1283+ description : 'Test description' ,
1284+ } ,
1285+ } ,
1286+ required : [ 'test' ] ,
1287+ } ,
1288+ } ,
1289+ } ,
1290+ } ,
1291+ } ,
1292+ } ,
1293+ } ,
1294+ } ,
1295+ components : {
1296+ schemas : { } ,
1297+ } ,
1298+ } ) ;
1299+
1300+ const ROUTE_WITH_ANY_AND_FORMAT = `
1301+ import * as t from 'io-ts';
1302+ import * as h from '@api-ts/io-ts-http';
1303+
1304+ /**
1305+ * A simple route
1306+ *
1307+ * @operationId api.v1.test
1308+ * @tag Test Routes
1309+ */
1310+ export const route = h.httpRoute({
1311+ path: '/foo',
1312+ method: 'GET',
1313+ request: h.httpRequest({}),
1314+ response: {
1315+ 200: {
1316+ /**
1317+ * @format binary
1318+ */
1319+ test: t.any
1320+ }
1321+ },
1322+ });
1323+ ` ;
1324+
1325+ testCase ( 'route with example object' , ROUTE_WITH_ANY_AND_FORMAT , {
1326+ openapi : '3.0.3' ,
1327+ info : {
1328+ title : 'Test' ,
1329+ version : '1.0.0' ,
1330+ } ,
1331+ paths : {
1332+ '/foo' : {
1333+ get : {
1334+ summary : 'A simple route' ,
1335+ operationId : 'api.v1.test' ,
1336+ tags : [ 'Test Routes' ] ,
1337+ parameters : [ ] ,
1338+ responses : {
1339+ 200 : {
1340+ description : 'OK' ,
1341+ content : {
1342+ 'application/json' : {
1343+ schema : {
1344+ type : 'object' ,
1345+ properties : {
1346+ test : {
1347+ format : 'binary' ,
1348+ } ,
1349+ } ,
1350+ required : [ 'test' ] ,
1351+ } ,
1352+ } ,
1353+ } ,
1354+ } ,
1355+ } ,
1356+ } ,
1357+ } ,
1358+ } ,
1359+ components : {
1360+ schemas : { } ,
1361+ } ,
1362+ } ) ;
You can’t perform that action at this time.
0 commit comments