-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): fixed openapi schema ref
Also small TypeScript 4.4 support fix fix #11
- Loading branch information
Showing
5 changed files
with
109 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ts-to-openapi typescript to openapi 1`] = ` | ||
"openapi: 3.0.0 | ||
info: | ||
title: My API | ||
version: v1 | ||
paths: {} | ||
$comment: >- | ||
Generated by core-types-json-schema | ||
(https://github.com/grantila/core-types-json-schema) on behalf of typeconv | ||
(https://github.com/grantila/typeconv) | ||
components: | ||
schemas: | ||
Foo: | ||
properties: | ||
a: | ||
type: string | ||
b: | ||
nullable: true | ||
c: | ||
type: number | ||
d: | ||
type: boolean | ||
e: | ||
$ref: '#/components/schemas/Thing' | ||
required: | ||
- a | ||
- b | ||
- c | ||
- d | ||
- e | ||
additionalProperties: false | ||
type: object | ||
Thing: | ||
properties: | ||
x: | ||
const: 6 | ||
type: number | ||
'y': | ||
type: string | ||
required: | ||
- x | ||
- 'y' | ||
additionalProperties: false | ||
type: object | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { makeConverter, getTypeScriptReader, getOpenApiWriter } from "../" | ||
|
||
|
||
describe( "ts-to-openapi", ( ) => | ||
{ | ||
it( "typescript to openapi", async ( ) => | ||
{ | ||
const input = ` | ||
type Thing = { | ||
x: 6 | ||
y: string | ||
} | ||
export type Foo = { | ||
a: string | ||
b: null | ||
c: number | ||
d: boolean | ||
e: Thing | ||
} | ||
`; | ||
|
||
const { convert } = makeConverter( | ||
getTypeScriptReader( ), | ||
getOpenApiWriter( { | ||
format: 'yaml', | ||
title: 'My API', | ||
version: 'v1' | ||
} ) | ||
); | ||
|
||
const { data } = await convert( { data: input } ); | ||
|
||
expect( data ).toMatchSnapshot( ); | ||
}); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters