diff --git a/package.json b/package.json index 4eccc22..afc1bd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@samchon/openapi", - "version": "0.4.1", + "version": "0.4.2", "description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", "main": "./lib/index.js", "module": "./lib/index.mjs", @@ -16,6 +16,8 @@ "keywords": [ "swagger", "openapi", + "converter", + "migrate", "typia", "nestia" ], diff --git a/src/IMigrateRoute.ts b/src/IMigrateRoute.ts index 11368e1..bd297d7 100644 --- a/src/IMigrateRoute.ts +++ b/src/IMigrateRoute.ts @@ -75,6 +75,8 @@ export interface IMigrateRoute< /** * List of path parameters. + * + * Note that, not a list of every parameters, but only path parameters. */ parameters: IMigrateRoute.IParameter[]; @@ -224,6 +226,8 @@ export namespace IMigrateRoute { schema: Schema; title: () => string | undefined; description: () => string | undefined; + example: () => any | undefined; + examples: () => Record | undefined; } /** @@ -237,6 +241,8 @@ export namespace IMigrateRoute { schema: Schema; title: () => string | undefined; description: () => string | undefined; + example: () => any | undefined; + examples: () => Record | undefined; } /** @@ -274,6 +280,11 @@ export namespace IMigrateRoute { */ description: () => string | undefined; + /** + * Media type of the request/response body. + */ + media: () => OpenApi.IOperation.IMediaType; + /** * Whether the body is encrypted or not. */ @@ -295,5 +306,10 @@ export namespace IMigrateRoute { * Description comment for the exception. */ response: () => OpenApi.IOperation.IResponse; + + /** + * Media type of the response body. + */ + media: () => OpenApi.IOperation.IMediaType; } } diff --git a/src/OpenApi.ts b/src/OpenApi.ts index ea0a0b7..440a896 100644 --- a/src/OpenApi.ts +++ b/src/OpenApi.ts @@ -506,9 +506,9 @@ export namespace OpenApi { * Request body of the operation. */ export interface IRequestBody { + content?: IContent; description?: string; required?: boolean; - content?: IContent; "x-nestia-encrypted"?: boolean; } @@ -516,8 +516,8 @@ export namespace OpenApi { * Response of the operation. */ export interface IResponse { - content?: IContent; headers?: Record>; + content?: IContent; description?: string; "x-nestia-encrypted"?: boolean; } diff --git a/src/internal/MigrateRouteConverter.ts b/src/internal/MigrateRouteConverter.ts index 6583fc3..b6bf40c 100644 --- a/src/internal/MigrateRouteConverter.ts +++ b/src/internal/MigrateRouteConverter.ts @@ -86,6 +86,8 @@ export namespace MigrateRouteConverter { schema: OpenApi.IJsonSchema; title?: string; description?: string; + example?: any; + examples?: Record; }) => ({ ...elem, @@ -93,6 +95,8 @@ export namespace MigrateRouteConverter { key: type, title: () => elem.title, description: () => elem.description, + example: () => elem.example, + examples: () => elem.examples, }) satisfies IMigrateRoute.IHeaders; if (objects.length === 1 && primitives.length === 0) @@ -269,6 +273,7 @@ export namespace MigrateRouteConverter { { schema: response.content?.["application/json"]?.schema ?? {}, response: () => response, + media: () => response.content?.["application/json"] ?? {}, }, ]), ), @@ -373,8 +378,9 @@ export namespace MigrateRouteConverter { ? schema : emplacer(schema) : {}, - "x-nestia-encrypted": meta["x-nestia-encrypted"], description: () => meta.description, + media: () => json[1], + "x-nestia-encrypted": meta["x-nestia-encrypted"], }; } @@ -393,6 +399,7 @@ export namespace MigrateRouteConverter { : emplacer(schema) : {}, description: () => meta.description, + media: () => query[1], }; } @@ -404,6 +411,7 @@ export namespace MigrateRouteConverter { key: "body", schema: { type: "string" }, description: () => meta.description, + media: () => text[1], }; if (from === "request") { @@ -422,6 +430,7 @@ export namespace MigrateRouteConverter { : emplacer(schema) : {}, description: () => meta.description, + media: () => multipart[1], }; } }