Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@samchon/openapi

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samchon/openapi - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

27

lib/internal/OpenApiV3_1Converter.js

@@ -162,9 +162,15 @@ "use strict";

const attribute = Object.assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
const nullable = { value: false };
const nullable = {
value: false,
default: undefined,
};
const visit = (schema) => {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f, _g, _h;
// NULLABLE PROPERTY
if (schema.nullable ===
true)
true) {
nullable.value || (nullable.value = true);
if (schema.default === null)
nullable.default = null;
}
// MIXED TYPE CASE

@@ -219,11 +225,11 @@ if (TypeChecker.isMixed(schema)) {

else
union.push(Object.assign(Object.assign({}, schema), {
union.push(Object.assign(Object.assign(Object.assign({}, schema), { default: (_d = schema.default) !== null && _d !== void 0 ? _d : undefined }), {
enum: undefined,
}));
else if (TypeChecker.isInteger(schema) || TypeChecker.isNumber(schema))
if ((_d = schema.enum) === null || _d === void 0 ? void 0 : _d.length)
if ((_e = schema.enum) === null || _e === void 0 ? void 0 : _e.length)
for (const value of schema.enum)
union.push(Object.assign({ const: value }, Object.assign(Object.assign({}, schema), { type: undefined, enum: undefined, default: undefined, minimum: undefined, maximum: undefined, exclusiveMinimum: undefined, exclusiveMaximum: undefined, multipleOf: undefined })));
else
union.push(Object.assign(Object.assign(Object.assign(Object.assign({}, schema), {
union.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, schema), { default: (_f = schema.default) !== null && _f !== void 0 ? _f : undefined }), {
enum: undefined,

@@ -246,7 +252,7 @@ }), (typeof schema.exclusiveMinimum === "number"

else if (TypeChecker.isString(schema))
if ((_e = schema.enum) === null || _e === void 0 ? void 0 : _e.length)
if ((_g = schema.enum) === null || _g === void 0 ? void 0 : _g.length)
for (const value of schema.enum)
union.push(Object.assign({ const: value }, Object.assign(Object.assign({}, schema), { type: undefined, enum: undefined, default: undefined })));
else
union.push(Object.assign(Object.assign({}, schema), {
union.push(Object.assign(Object.assign(Object.assign({}, schema), { default: (_h = schema.default) !== null && _h !== void 0 ? _h : undefined }), {
enum: undefined,

@@ -313,3 +319,6 @@ }));

!union.some((e) => e.type === "null"))
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return Object.assign(Object.assign(Object.assign({}, (union.length === 0

@@ -316,0 +325,0 @@ ? { type: undefined }

@@ -146,11 +146,17 @@ "use strict";

OpenApiV3Converter.convertSchema = (components) => (input) => {
const nullable = { value: false };
const nullable = {
value: false,
default: undefined,
};
const union = [];
const attribute = Object.assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
const visit = (schema) => {
var _a;
var _a, _b;
// NULLABLE PROPERTY
if (schema.nullable ===
true)
true) {
nullable.value || (nullable.value = true);
if (schema.default === null)
nullable.default = null;
}
// UNION TYPE CASE

@@ -171,3 +177,3 @@ if (TypeChecker.isAnyOf(schema))

else
union.push(Object.assign(Object.assign({}, schema), { enum: undefined }));
union.push(Object.assign(Object.assign(Object.assign({}, schema), { default: ((_b = schema.default) !== null && _b !== void 0 ? _b : undefined) }), { enum: undefined }));
// INSTANCE TYPE CASE

@@ -201,3 +207,6 @@ else if (TypeChecker.isArray(schema))

!union.some((e) => e.type === "null"))
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return Object.assign(Object.assign(Object.assign({}, (union.length === 0

@@ -204,0 +213,0 @@ ? { type: undefined }

@@ -198,11 +198,17 @@ "use strict";

const convertSchema = (input) => {
const nullable = { value: false };
const nullable = {
value: false,
default: undefined,
};
const union = [];
const attribute = Object.assign({ title: input.title, description: input.description }, Object.fromEntries(Object.entries(input).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
const visit = (schema) => {
var _a;
var _a, _b;
// NULLABLE PROPERTY
if (schema["x-nullable"] ===
true)
true) {
nullable.value || (nullable.value = true);
if (schema.default === null)
nullable.default = null;
}
// UNION TYPE CASE

@@ -221,3 +227,3 @@ if (TypeChecker.isAnyOf(schema))

else
union.push(Object.assign(Object.assign({}, schema), { enum: undefined }));
union.push(Object.assign(Object.assign(Object.assign({}, schema), { default: ((_b = schema.default) !== null && _b !== void 0 ? _b : undefined) }), { enum: undefined }));
// INSTANCE TYPE CASE

@@ -248,3 +254,6 @@ else if (TypeChecker.isArray(schema))

!union.some((e) => e.type === "null"))
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return Object.assign(Object.assign(Object.assign({}, (union.length === 0

@@ -251,0 +260,0 @@ ? { type: undefined }

@@ -814,2 +814,6 @@ import { IMigrateDocument } from "./IMigrateDocument";

interface INull extends __ISignificant<"null"> {
/**
* Default value.
*/
default?: null;
}

@@ -816,0 +820,0 @@ /**

@@ -123,3 +123,3 @@ /**

type: Array<"boolean" | "integer" | "number" | "string" | "array" | "object">;
default?: any[];
default?: any[] | null;
enum?: any[];

@@ -131,7 +131,7 @@ }

interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -149,3 +149,3 @@ /** @type int64 */ minimum?: number;

interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -160,3 +160,3 @@ minimum?: number;

contentMediaType?: string;
default?: string;
default?: string | null;
enum?: string[];

@@ -172,2 +172,3 @@ format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {});

interface INull extends __ISignificant<"null"> {
default?: null;
}

@@ -174,0 +175,0 @@ interface IAllOf extends __IAttribute {

@@ -118,7 +118,7 @@ /**

interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -136,3 +136,3 @@ /** @type int64 */ minimum?: number;

interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -146,3 +146,3 @@ minimum?: number;

interface IString extends __ISignificant<"string"> {
default?: string;
default?: string | null;
enum?: string[];

@@ -175,2 +175,3 @@ format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {});

type: "null";
default?: null;
}

@@ -177,0 +178,0 @@ interface IAllOf extends __IAttribute {

@@ -87,7 +87,7 @@ /**

interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -105,3 +105,3 @@ /** @type int64 */ minimum?: number;

interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -115,3 +115,3 @@ minimum?: number;

interface IString extends __ISignificant<"string"> {
default?: string;
default?: string | null;
enum?: string[];

@@ -144,2 +144,3 @@ format?: "binary" | "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | (string & {});

type: "null";
default?: null;
}

@@ -146,0 +147,0 @@ interface IAllOf extends __IAttribute {

{
"name": "@samchon/openapi",
"version": "0.4.2",
"version": "0.4.3",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",

@@ -39,4 +39,6 @@ "main": "./lib/index.js",

"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.12.7",
"chalk": "^4.1.2",
"js-yaml": "^4.1.0",
"prettier": "^3.2.5",

@@ -54,3 +56,4 @@ "rimraf": "^5.0.5",

"README.md"
]
],
"packageManager": "pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
}

@@ -285,3 +285,6 @@ import { OpenApi } from "../OpenApi";

};
const nullable: { value: boolean } = { value: false };
const nullable: { value: boolean; default?: null } = {
value: false,
default: undefined,
};

@@ -293,4 +296,7 @@ const visit = (schema: OpenApiV3_1.IJsonSchema): void => {

true
)
) {
nullable.value ||= true;
if ((schema as OpenApiV3_1.IJsonSchema.INumber).default === null)
nullable.default = null;
}
// MIXED TYPE CASE

@@ -369,2 +375,3 @@ if (TypeChecker.isMixed(schema)) {

...schema,
default: schema.default ?? undefined,
...{

@@ -394,2 +401,3 @@ enum: undefined,

...schema,
default: schema.default ?? undefined,
...{

@@ -430,2 +438,3 @@ enum: undefined,

...schema,
default: schema.default ?? undefined,
...{

@@ -521,3 +530,6 @@ enum: undefined,

)
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return {

@@ -524,0 +536,0 @@ ...(union.length === 0

@@ -247,3 +247,6 @@ import { OpenApi } from "../OpenApi";

(input: OpenApiV3.IJsonSchema): OpenApi.IJsonSchema => {
const nullable: { value: boolean } = { value: false };
const nullable: { value: boolean; default?: null } = {
value: false,
default: undefined,
};
const union: OpenApi.IJsonSchema[] = [];

@@ -264,4 +267,7 @@ const attribute: OpenApi.IJsonSchema.__IAttribute = {

true
)
) {
nullable.value ||= true;
if ((schema as OpenApiV3.IJsonSchema.INumber).default === null)
nullable.default = null;
}
// UNION TYPE CASE

@@ -284,2 +290,7 @@ if (TypeChecker.isAnyOf(schema)) schema.anyOf.forEach(visit);

...schema,
default: (schema.default ?? undefined) satisfies
| boolean
| number
| string
| undefined as any,
...{ enum: undefined },

@@ -324,3 +335,6 @@ });

)
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return {

@@ -327,0 +341,0 @@ ...(union.length === 0

@@ -222,3 +222,3 @@ import { OpenApi } from "../OpenApi";

return {
oneOf: elements.map(downgradeSchema(collection)),
oneOf: elements.map(downgradeSchema(collection) as any),
};

@@ -280,4 +280,4 @@ })(),

for (const u of union)
if (OpenApiTypeChecker.isReference(u))
downgradeNullableReference(collection)(u);
if (OpenApiTypeChecker.isReference(u as any))
downgradeNullableReference(collection)(u as any);
else (u as OpenApiV3.IJsonSchema.IArray).nullable = true;

@@ -284,0 +284,0 @@ if (nullable === true && union.length === 0)

@@ -255,3 +255,6 @@ import { OpenApi } from "../OpenApi";

const convertSchema = (input: SwaggerV2.IJsonSchema): OpenApi.IJsonSchema => {
const nullable: { value: boolean } = { value: false };
const nullable: { value: boolean; default?: null } = {
value: false,
default: undefined,
};
const union: OpenApi.IJsonSchema[] = [];

@@ -272,4 +275,7 @@ const attribute: OpenApi.IJsonSchema.__IAttribute = {

true
)
) {
nullable.value ||= true;
if ((schema as SwaggerV2.IJsonSchema.INumber).default === null)
nullable.default = null;
}
// UNION TYPE CASE

@@ -290,2 +296,7 @@ if (TypeChecker.isAnyOf(schema)) schema["x-anyOf"].forEach(visit);

...schema,
default: (schema.default ?? undefined) satisfies
| boolean
| number
| string
| undefined as any,
...{ enum: undefined },

@@ -331,3 +342,6 @@ });

)
union.push({ type: "null" });
union.push({
type: "null",
default: nullable.default,
});
return {

@@ -334,0 +348,0 @@ ...(union.length === 0

@@ -234,3 +234,3 @@ import { OpenApi } from "../OpenApi";

return {
"x-oneOf": elements.map(downgradeSchema(collection)),
"x-oneOf": elements.map(downgradeSchema(collection) as any),
};

@@ -290,4 +290,4 @@ })(),

for (const u of union)
if (OpenApiTypeChecker.isReference(u))
downgradeNullableReference(collection)(u);
if (OpenApiTypeChecker.isReference(u as any))
downgradeNullableReference(collection)(u as any);
else (u as SwaggerV2.IJsonSchema.IArray)["x-nullable"] = true;

@@ -294,0 +294,0 @@

@@ -1035,3 +1035,8 @@ import { IMigrateDocument } from "./IMigrateDocument";

*/
export interface INull extends __ISignificant<"null"> {}
export interface INull extends __ISignificant<"null"> {
/**
* Default value.
*/
default?: null;
}

@@ -1038,0 +1043,0 @@ /**

@@ -204,3 +204,3 @@ /**

>;
default?: any[];
default?: any[] | null;
enum?: any[];

@@ -213,7 +213,7 @@ }

export interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
export interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -231,3 +231,3 @@ /** @type int64 */ minimum?: number;

export interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -242,3 +242,3 @@ minimum?: number;

contentMediaType?: string;
default?: string;
default?: string | null;
enum?: string[];

@@ -278,3 +278,5 @@ format?:

}
export interface INull extends __ISignificant<"null"> {}
export interface INull extends __ISignificant<"null"> {
default?: null;
}
export interface IAllOf extends __IAttribute {

@@ -281,0 +283,0 @@ allOf: IJsonSchema[];

@@ -183,7 +183,7 @@ /**

export interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
export interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -201,3 +201,3 @@ /** @type int64 */ minimum?: number;

export interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -211,3 +211,3 @@ minimum?: number;

export interface IString extends __ISignificant<"string"> {
default?: string;
default?: string | null;
enum?: string[];

@@ -266,2 +266,3 @@ format?:

type: "null";
default?: null;
}

@@ -268,0 +269,0 @@ export interface IAllOf extends __IAttribute {

@@ -133,7 +133,7 @@ /**

export interface IBoolean extends __ISignificant<"boolean"> {
default?: boolean;
default?: boolean | null;
enum?: boolean[];
}
export interface IInteger extends __ISignificant<"integer"> {
/** @type int64 */ default?: number;
/** @type int64 */ default?: number | null;
/** @type int64 */ enum?: number[];

@@ -151,3 +151,3 @@ /** @type int64 */ minimum?: number;

export interface INumber extends __ISignificant<"number"> {
default?: number;
default?: number | null;
enum?: number[];

@@ -161,3 +161,3 @@ minimum?: number;

export interface IString extends __ISignificant<"string"> {
default?: string;
default?: string | null;
enum?: string[];

@@ -216,2 +216,3 @@ format?:

type: "null";
default?: null;
}

@@ -218,0 +219,0 @@ export interface IAllOf extends __IAttribute {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc