Skip to content

Commit e040baa

Browse files
committed
test(annotations): ensured annotations from typescript is forwarded to openapi
re #13
1 parent 9807691 commit e040baa

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

lib/tests/__snapshots__/ts-to-openapi.test.ts.snap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,31 @@ components:
4747
type: object
4848
"
4949
`;
50+
51+
exports[`ts-to-openapi typescript to openapi 2`] = `
52+
"openapi: 3.0.0
53+
info:
54+
title: My API
55+
version: v1
56+
x-comment: >-
57+
Generated by core-types-json-schema
58+
(https://github.com/grantila/core-types-json-schema) on behalf of typeconv
59+
(https://github.com/grantila/typeconv)
60+
paths: {}
61+
components:
62+
schemas:
63+
Point:
64+
properties:
65+
x:
66+
title: The distance from the left in mm
67+
type: number
68+
'y':
69+
title: The distance from the top in mm
70+
type: number
71+
required:
72+
- x
73+
- 'y'
74+
additionalProperties: false
75+
type: object
76+
"
77+
`;

lib/tests/ts-to-openapi.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,29 @@ describe( "ts-to-openapi", ( ) =>
3333

3434
expect( data ).toMatchSnapshot( );
3535
} );
36+
37+
it( "typescript to openapi", async ( ) =>
38+
{
39+
const input = `
40+
export type Point = {
41+
/** The distance from the left in mm */
42+
x: number;
43+
/** The distance from the top in mm */
44+
y: number;
45+
};
46+
`;
47+
48+
const { convert } = makeConverter(
49+
getTypeScriptReader( ),
50+
getOpenApiWriter( {
51+
format: 'yaml',
52+
title: 'My API',
53+
version: 'v1'
54+
} )
55+
);
56+
57+
const { data } = await convert( { data: input } );
58+
59+
expect( data ).toMatchSnapshot( );
60+
} );
3661
} );

0 commit comments

Comments
 (0)