Skip to content

Commit

Permalink
Merge pull request #38 from samchon/feature/mixed
Browse files Browse the repository at this point in the history
Change migration rule.
  • Loading branch information
samchon authored Aug 13, 2024
2 parents 9171a99 + 68c5a23 commit eacc873
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
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.4.4",
"version": "0.4.5",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
Expand Down
59 changes: 30 additions & 29 deletions src/internal/MigrateRouteConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,49 +358,50 @@ export namespace MigrateRouteConverter {

const entries: [string, OpenApi.IOperation.IMediaType][] = Object.entries(
meta.content,
).filter(([_, v]) => !!v?.schema) as [
string,
OpenApi.IOperation.IMediaType,
][];
).filter(([_, v]) => !!v) as [string, OpenApi.IOperation.IMediaType][];
const json = entries.find((e) =>
meta["x-nestia-encrypted"] === true
? e[0].includes("text/plain") || e[0].includes("application/json")
: e[0].includes("application/json") || e[0].includes("*/*"),
);
if (json) {
const { schema } = json[1];
return {
type: "application/json",
name: "body",
key: "body",
schema: schema
? isNotObjectLiteral(schema)
? schema
: emplacer(schema)
: {},
description: () => meta.description,
media: () => json[1],
"x-nestia-encrypted": meta["x-nestia-encrypted"],
};
return schema || from === "request"
? {
type: "application/json",
name: "body",
key: "body",
schema: schema
? isNotObjectLiteral(schema)
? schema
: emplacer(schema)
: {},
description: () => meta.description,
media: () => json[1],
"x-nestia-encrypted": meta["x-nestia-encrypted"],
}
: null;
}

const query = entries.find((e) =>
e[0].includes("application/x-www-form-urlencoded"),
);
if (query) {
const { schema } = query[1];
return {
type: "application/x-www-form-urlencoded",
name: "body",
key: "body",
schema: schema
? isNotObjectLiteral(schema)
? schema
: emplacer(schema)
: {},
description: () => meta.description,
media: () => query[1],
};
return schema || from === "request"
? {
type: "application/x-www-form-urlencoded",
name: "body",
key: "body",
schema: schema
? isNotObjectLiteral(schema)
? schema
: emplacer(schema)
: {},
description: () => meta.description,
media: () => query[1],
}
: null;
}

const text = entries.find((e) => e[0].includes("text/plain"));
Expand Down

0 comments on commit eacc873

Please sign in to comment.