Skip to content

Commit

Permalink
test(annotations): ensured annotations from typescript is forwarded t…
Browse files Browse the repository at this point in the history
…o openapi

re #13
  • Loading branch information
grantila committed Oct 17, 2021
1 parent 9807691 commit e040baa
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/tests/__snapshots__/ts-to-openapi.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,31 @@ components:
type: object
"
`;

exports[`ts-to-openapi typescript to openapi 2`] = `
"openapi: 3.0.0
info:
title: My API
version: v1
x-comment: >-
Generated by core-types-json-schema
(https://github.com/grantila/core-types-json-schema) on behalf of typeconv
(https://github.com/grantila/typeconv)
paths: {}
components:
schemas:
Point:
properties:
x:
title: The distance from the left in mm
type: number
'y':
title: The distance from the top in mm
type: number
required:
- x
- 'y'
additionalProperties: false
type: object
"
`;
25 changes: 25 additions & 0 deletions lib/tests/ts-to-openapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,29 @@ describe( "ts-to-openapi", ( ) =>

expect( data ).toMatchSnapshot( );
} );

it( "typescript to openapi", async ( ) =>
{
const input = `
export type Point = {
/** The distance from the left in mm */
x: number;
/** The distance from the top in mm */
y: number;
};
`;

const { convert } = makeConverter(
getTypeScriptReader( ),
getOpenApiWriter( {
format: 'yaml',
title: 'My API',
version: 'v1'
} )
);

const { data } = await convert( { data: input } );

expect( data ).toMatchSnapshot( );
} );
} );

0 comments on commit e040baa

Please sign in to comment.