@samchon/openapi
Advanced tools
Comparing version 0.1.23-dev.20240626 to 0.1.23-dev.20240627
@@ -0,1 +1,3 @@ | ||
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateDocument"; | ||
export * from "./OpenApi"; | ||
@@ -2,0 +4,0 @@ export * from "./SwaggerV2"; |
@@ -17,2 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./IMigrateRoute"), exports); | ||
__exportStar(require("./IMigrateDocument"), exports); | ||
__exportStar(require("./OpenApi"), exports); | ||
@@ -19,0 +21,0 @@ __exportStar(require("./SwaggerV2"), exports); |
@@ -0,1 +1,2 @@ | ||
import { IMigrateDocument } from "./IMigrateDocument"; | ||
import { OpenApiV3 } from "./OpenApiV3"; | ||
@@ -45,3 +46,3 @@ import { OpenApiV3_1 } from "./OpenApiV3_1"; | ||
*/ | ||
const convert: (input: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument) => IDocument; | ||
function convert(input: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument): IDocument; | ||
/** | ||
@@ -58,2 +59,3 @@ * Downgrade to Swagger v2.0 document. | ||
function downgrade(document: IDocument, version: "3.0"): OpenApiV3.IDocument; | ||
function migrate(document: IDocument): IMigrateDocument; | ||
interface IDocument { | ||
@@ -60,0 +62,0 @@ openapi: `3.1.${number}`; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const SwaggerV2_1 = require("./SwaggerV2"); | ||
const MigrateConverter_1 = require("./internal/MigrateConverter"); | ||
const OpenApiV3Converter_1 = require("./internal/OpenApiV3Converter"); | ||
@@ -54,3 +55,3 @@ const OpenApiV3Downgrader_1 = require("./internal/OpenApiV3Downgrader"); | ||
*/ | ||
OpenApi.convert = (input) => { | ||
function convert(input) { | ||
if (OpenApiV3_1_1.OpenApiV3_1.is(input)) | ||
@@ -63,3 +64,4 @@ return OpenApiV3_1Converter_1.OpenApiV3_1Converter.convert(input); | ||
throw new TypeError("Unrecognized Swagger/OpenAPI version."); | ||
}; | ||
} | ||
OpenApi.convert = convert; | ||
/** | ||
@@ -82,2 +84,6 @@ * Downgrade to OpenAPI v2.3 document. | ||
OpenApi.downgrade = downgrade; | ||
function migrate(document) { | ||
return MigrateConverter_1.MigrateConverter.convert(document); | ||
} | ||
OpenApi.migrate = migrate; | ||
})(OpenApi || (exports.OpenApi = OpenApi = {})); |
{ | ||
"name": "@samchon/openapi", | ||
"version": "0.1.23-dev.20240626", | ||
"version": "0.1.23-dev.20240627", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -48,3 +48,9 @@ # `@samchon/openapi` | ||
```typescript | ||
import { OpenApi, SwaggerV2, OpenApiV3, OpenApiV3_1 } from "@samchon/openapi"; | ||
import { | ||
OpenApi, | ||
SwaggerV2, | ||
OpenApiV3, | ||
OpenApiV3_1, | ||
IMigrateDocument, | ||
} from "@samchon/openapi"; | ||
@@ -68,2 +74,7 @@ // original Swagger/OpenAPI document | ||
OpenApi.downgrade(OpenApi.convert(v3), "2.0"); | ||
// also supports openapi generator libraries | ||
const migrate: IMigrateDocument = OpenApi.migrate( | ||
OpenApi.convert(input), | ||
); | ||
``` | ||
@@ -70,0 +81,0 @@ |
@@ -1,3 +0,3 @@ | ||
export * from "./IMigrateOperation"; | ||
export * from "./IMigrationResult"; | ||
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateDocument"; | ||
export * from "./OpenApi"; | ||
@@ -4,0 +4,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { IMigrationResult } from "./IMigrationResult"; | ||
import { IMigrateDocument } from "./IMigrateDocument"; | ||
import { OpenApiV3 } from "./OpenApiV3"; | ||
import { OpenApiV3_1 } from "./OpenApiV3_1"; | ||
import { SwaggerV2 } from "./SwaggerV2"; | ||
import { MigrationConverter } from "./internal/MigrationConverter"; | ||
import { MigrateConverter } from "./internal/MigrateConverter"; | ||
import { OpenApiV3Converter } from "./internal/OpenApiV3Converter"; | ||
@@ -111,4 +111,4 @@ import { OpenApiV3Downgrader } from "./internal/OpenApiV3Downgrader"; | ||
export function migrate(document: IDocument): IMigrationResult { | ||
return MigrationConverter.convert(document); | ||
export function migrate(document: IDocument): IMigrateDocument { | ||
return MigrateConverter.convert(document); | ||
} | ||
@@ -115,0 +115,0 @@ |
300013
63
7440
86