Skip to content

Commit

Permalink
Merge pull request #8 from samchon/features/recursiveRef
Browse files Browse the repository at this point in the history
`OpenApi.convert()` can accept `OpenApi.IDocument` itself.
  • Loading branch information
samchon authored Apr 12, 2024
2 parents 9346f25 + ce4b7ef commit 1f9821c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import { OpenApi, SwaggerV2, OpenApiV3, OpenApiV3_1 } from "@samchon/openapi";
const input:
| SwaggerV2.IDocument
| OpenApiV3.IDocument
| OpenApiV3_1.IDocument = { ... };
| OpenApiV3_1.IDocument
| OpenApi.IDocument = { ... };

// you can convert it to emended OpenAPI v3.1
const output: OpenApi.IDocument = OpenApi.convert(input);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samchon/openapi",
"version": "0.1.6",
"version": "0.1.7",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand Down
6 changes: 5 additions & 1 deletion src/OpenApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export namespace OpenApi {
* @returns Emended OpenAPI v3.1 document
*/
export const convert = (
input: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument,
input:
| SwaggerV2.IDocument
| OpenApiV3.IDocument
| OpenApiV3_1.IDocument
| OpenApi.IDocument,
): IDocument => {
if (OpenApiV3_1.is(input)) return OpenApiV3_1Converter.convert(input);
else if (OpenApiV3.is(input)) return OpenApiV3Converter.convert(input);
Expand Down
6 changes: 5 additions & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ console.log("Test OpenAPI conversion");

const validate = (
title: string,
document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument,
document:
| SwaggerV2.IDocument
| OpenApiV3.IDocument
| OpenApiV3_1.IDocument
| OpenApi.IDocument,
): OpenApi.IDocument => {
console.log(" -", title);
console.log(" - type assertion");
Expand Down

0 comments on commit 1f9821c

Please sign in to comment.