typia
Version:
Superfast runtime validators with only one line
29 lines (27 loc) • 687 B
text/typescript
import { OpenApiV3 } from "@samchon/openapi";
/**
* @internal
*/
export const application_v30_native =
(components: OpenApiV3.IComponents) =>
(name: string) =>
(nullable: boolean): OpenApiV3.IJsonSchema => {
if (name === "Blob" || name === "File")
return {
type: "string",
format: "binary",
nullable,
};
const key: string = `${name}${nullable ? ".Nullable" : ""}`;
if (components.schemas?.[key] === undefined) {
components.schemas ??= {};
components.schemas[key] ??= {
type: "object",
properties: {},
nullable,
};
}
return {
$ref: `#/components/schemas/${key}`,
};
};