@samchon/openapi
Advanced tools
Comparing version 0.3.0 to 0.3.1
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateDocument"; | ||
export * from "./OpenApi"; | ||
export * from "./OpenApiTypeChecker"; | ||
export * from "./SwaggerV2"; | ||
export * from "./OpenApiV3"; | ||
export * from "./OpenApiV3_1"; |
@@ -20,4 +20,5 @@ "use strict"; | ||
__exportStar(require("./OpenApi"), exports); | ||
__exportStar(require("./OpenApiTypeChecker"), exports); | ||
__exportStar(require("./SwaggerV2"), exports); | ||
__exportStar(require("./OpenApiV3"), exports); | ||
__exportStar(require("./OpenApiV3_1"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MigrateRouteConverter = void 0; | ||
const OpenApiTypeChecker_1 = require("../OpenApiTypeChecker"); | ||
const Escaper_1 = require("../utils/Escaper"); | ||
const StringUtil_1 = require("../utils/StringUtil"); | ||
const OpenApiTypeChecker_1 = require("./OpenApiTypeChecker"); | ||
var MigrateRouteConverter; | ||
@@ -8,0 +8,0 @@ (function (MigrateRouteConverter) { |
@@ -1,15 +0,1 @@ | ||
import { OpenApi } from "../OpenApi"; | ||
export declare namespace OpenApiTypeChecker { | ||
const isNull: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.INull; | ||
const isUnknown: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IUnknown; | ||
const isConstant: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IConstant; | ||
const isBoolean: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IBoolean; | ||
const isInteger: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IInteger; | ||
const isNumber: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.INumber; | ||
const isString: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IString; | ||
const isArray: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IArray; | ||
const isTuple: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.ITuple; | ||
const isObject: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IObject; | ||
const isReference: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IReference; | ||
const isOneOf: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IOneOf; | ||
} | ||
export * from "../OpenApiTypeChecker"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OpenApiTypeChecker = void 0; | ||
var OpenApiTypeChecker; | ||
(function (OpenApiTypeChecker) { | ||
OpenApiTypeChecker.isNull = (schema) => schema.type === "null"; | ||
OpenApiTypeChecker.isUnknown = (schema) => schema.type === undefined && | ||
!OpenApiTypeChecker.isConstant(schema) && | ||
!OpenApiTypeChecker.isOneOf(schema) && | ||
!OpenApiTypeChecker.isReference(schema); | ||
OpenApiTypeChecker.isConstant = (schema) => schema.const !== undefined; | ||
OpenApiTypeChecker.isBoolean = (schema) => schema.type === "boolean"; | ||
OpenApiTypeChecker.isInteger = (schema) => schema.type === "integer"; | ||
OpenApiTypeChecker.isNumber = (schema) => schema.type === "number"; | ||
OpenApiTypeChecker.isString = (schema) => schema.type === "string"; | ||
OpenApiTypeChecker.isArray = (schema) => schema.type === "array" && | ||
schema.items !== undefined; | ||
OpenApiTypeChecker.isTuple = (schema) => schema.type === "array" && | ||
schema.prefixItems !== undefined; | ||
OpenApiTypeChecker.isObject = (schema) => schema.type === "object"; | ||
OpenApiTypeChecker.isReference = (schema) => schema.$ref !== undefined; | ||
OpenApiTypeChecker.isOneOf = (schema) => schema.oneOf !== undefined; | ||
})(OpenApiTypeChecker || (exports.OpenApiTypeChecker = OpenApiTypeChecker = {})); | ||
// FOR LEGACY VERSIONS | ||
__exportStar(require("../OpenApiTypeChecker"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OpenApiV3Downgrader = void 0; | ||
const OpenApiTypeChecker_1 = require("./OpenApiTypeChecker"); | ||
const OpenApiTypeChecker_1 = require("../OpenApiTypeChecker"); | ||
var OpenApiV3Downgrader; | ||
@@ -6,0 +6,0 @@ (function (OpenApiV3Downgrader) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SwaggerV2Downgrader = void 0; | ||
const OpenApiTypeChecker_1 = require("./OpenApiTypeChecker"); | ||
const OpenApiTypeChecker_1 = require("../OpenApiTypeChecker"); | ||
var SwaggerV2Downgrader; | ||
@@ -198,6 +198,6 @@ (function (SwaggerV2Downgrader) { | ||
return Object.assign({ type: "null" }, attribute); | ||
return Object.assign(Object.assign({}, (union.length === 0 | ||
return Object.assign(Object.assign(Object.assign({}, (union.length === 0 | ||
? { type: undefined } | ||
: union.length === 1 | ||
? Object.assign({}, union[0]) : { "x-oneOf": union.map((u) => (Object.assign(Object.assign({}, u), { nullable: undefined }))) })), attribute); | ||
? Object.assign({}, union[0]) : { "x-oneOf": union.map((u) => (Object.assign(Object.assign({}, u), { nullable: undefined }))) })), attribute), (union.length > 1 ? { discriminator: undefined } : {})); | ||
}; | ||
@@ -204,0 +204,0 @@ const downgradeNullableReference = (collection) => (schema) => { |
@@ -288,3 +288,3 @@ import { IMigrateDocument } from "./IMigrateDocument"; | ||
* `OpenApi.IPath` represents a path item of emended OpenAPI v3.1, | ||
* collecting multiple method operations in a signgle path. | ||
* collecting multiple method operations in a single path. | ||
*/ | ||
@@ -590,3 +590,3 @@ interface IPath<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>> extends Partial<Record<Method, Operation>> { | ||
/** | ||
* Array type. | ||
* Array type info. | ||
*/ | ||
@@ -773,3 +773,27 @@ interface IArray<Schema extends IJsonSchema = IJsonSchema> extends __ISignificant<"array"> { | ||
oneOf: Exclude<Schema, IJsonSchema.IOneOf>[]; | ||
/** | ||
* Discriminator info of the union type. | ||
*/ | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
namespace IOneOf { | ||
/** | ||
* Discriminator info of the union type. | ||
*/ | ||
interface IDiscriminator { | ||
/** | ||
* Property name for the discriminator. | ||
*/ | ||
propertyName: string; | ||
/** | ||
* Mapping of the discriminator value to the schema name. | ||
* | ||
* This property is valid only for {@link IReference} typed | ||
* {@link IOneOf.oneof} elements. Therefore, `key` of `mapping` is | ||
* the discriminator value, and `value` of `mapping` is the | ||
* schema name like `#/components/schemas/SomeObject`. | ||
*/ | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
/** | ||
@@ -776,0 +800,0 @@ * Null type. |
@@ -166,3 +166,10 @@ /** | ||
oneOf: IJsonSchema[]; | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
namespace IOneOf { | ||
interface IDiscriminator { | ||
propertyName: string; | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
interface IArray extends __ISignificant<"array"> { | ||
@@ -169,0 +176,0 @@ items: IJsonSchema | IJsonSchema[]; |
@@ -170,3 +170,10 @@ /** | ||
oneOf: IJsonSchema[]; | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
namespace IOneOf { | ||
interface IDiscriminator { | ||
propertyName: string; | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
interface __ISignificant<Type extends string> extends __IAttribute { | ||
@@ -173,0 +180,0 @@ type: Type; |
{ | ||
"name": "@samchon/openapi", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
export * from "./IMigrateRoute"; | ||
export * from "./IMigrateDocument"; | ||
export * from "./OpenApi"; | ||
export * from "./OpenApiTypeChecker"; | ||
@@ -5,0 +6,0 @@ export * from "./SwaggerV2"; |
import { IMigrateRoute } from "../IMigrateRoute"; | ||
import { OpenApi } from "../OpenApi"; | ||
import { OpenApiTypeChecker } from "../OpenApiTypeChecker"; | ||
import { Escaper } from "../utils/Escaper"; | ||
import { StringUtil } from "../utils/StringUtil"; | ||
import { OpenApiTypeChecker } from "./OpenApiTypeChecker"; | ||
@@ -7,0 +7,0 @@ export namespace MigrateRouteConverter { |
@@ -1,59 +0,2 @@ | ||
import { OpenApi } from "../OpenApi"; | ||
export namespace OpenApiTypeChecker { | ||
export const isNull = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.INull => | ||
(schema as OpenApi.IJsonSchema.INull).type === "null"; | ||
export const isUnknown = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IUnknown => | ||
(schema as OpenApi.IJsonSchema.IUnknown).type === undefined && | ||
!isConstant(schema) && | ||
!isOneOf(schema) && | ||
!isReference(schema); | ||
export const isConstant = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IConstant => | ||
(schema as OpenApi.IJsonSchema.IConstant).const !== undefined; | ||
export const isBoolean = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IBoolean => | ||
(schema as OpenApi.IJsonSchema.IBoolean).type === "boolean"; | ||
export const isInteger = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IInteger => | ||
(schema as OpenApi.IJsonSchema.IInteger).type === "integer"; | ||
export const isNumber = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.INumber => | ||
(schema as OpenApi.IJsonSchema.INumber).type === "number"; | ||
export const isString = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IString => | ||
(schema as OpenApi.IJsonSchema.IString).type === "string"; | ||
export const isArray = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IArray => | ||
(schema as OpenApi.IJsonSchema.IArray).type === "array" && | ||
(schema as OpenApi.IJsonSchema.IArray).items !== undefined; | ||
export const isTuple = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.ITuple => | ||
(schema as OpenApi.IJsonSchema.ITuple).type === "array" && | ||
(schema as OpenApi.IJsonSchema.ITuple).prefixItems !== undefined; | ||
export const isObject = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IObject => | ||
(schema as OpenApi.IJsonSchema.IObject).type === "object"; | ||
export const isReference = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IReference => | ||
(schema as any).$ref !== undefined; | ||
export const isOneOf = ( | ||
schema: OpenApi.IJsonSchema, | ||
): schema is OpenApi.IJsonSchema.IOneOf => | ||
(schema as OpenApi.IJsonSchema.IOneOf).oneOf !== undefined; | ||
} | ||
// FOR LEGACY VERSIONS | ||
export * from "../OpenApiTypeChecker"; |
import { OpenApi } from "../OpenApi"; | ||
import { OpenApiTypeChecker } from "../OpenApiTypeChecker"; | ||
import { OpenApiV3 } from "../OpenApiV3"; | ||
import { OpenApiTypeChecker } from "./OpenApiTypeChecker"; | ||
@@ -5,0 +5,0 @@ export namespace OpenApiV3Downgrader { |
import { OpenApi } from "../OpenApi"; | ||
import { OpenApiTypeChecker } from "../OpenApiTypeChecker"; | ||
import { SwaggerV2 } from "../SwaggerV2"; | ||
import { OpenApiTypeChecker } from "./OpenApiTypeChecker"; | ||
@@ -294,2 +294,3 @@ export namespace SwaggerV2Downgrader { | ||
...attribute, | ||
...(union.length > 1 ? { discriminator: undefined } : {}), | ||
}; | ||
@@ -296,0 +297,0 @@ }; |
@@ -399,3 +399,3 @@ import { IMigrateDocument } from "./IMigrateDocument"; | ||
* `OpenApi.IPath` represents a path item of emended OpenAPI v3.1, | ||
* collecting multiple method operations in a signgle path. | ||
* collecting multiple method operations in a single path. | ||
*/ | ||
@@ -791,3 +791,3 @@ export interface IPath< | ||
/** | ||
* Array type. | ||
* Array type info. | ||
*/ | ||
@@ -991,4 +991,30 @@ export interface IArray<Schema extends IJsonSchema = IJsonSchema> | ||
oneOf: Exclude<Schema, IJsonSchema.IOneOf>[]; | ||
/** | ||
* Discriminator info of the union type. | ||
*/ | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
export namespace IOneOf { | ||
/** | ||
* Discriminator info of the union type. | ||
*/ | ||
export interface IDiscriminator { | ||
/** | ||
* Property name for the discriminator. | ||
*/ | ||
propertyName: string; | ||
/** | ||
* Mapping of the discriminator value to the schema name. | ||
* | ||
* This property is valid only for {@link IReference} typed | ||
* {@link IOneOf.oneof} elements. Therefore, `key` of `mapping` is | ||
* the discriminator value, and `value` of `mapping` is the | ||
* schema name like `#/components/schemas/SomeObject`. | ||
*/ | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
/** | ||
@@ -995,0 +1021,0 @@ * Null type. |
@@ -265,3 +265,10 @@ /** | ||
oneOf: IJsonSchema[]; | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
export namespace IOneOf { | ||
export interface IDiscriminator { | ||
propertyName: string; | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
@@ -268,0 +275,0 @@ export interface IArray extends __ISignificant<"array"> { |
@@ -254,3 +254,10 @@ /** | ||
oneOf: IJsonSchema[]; | ||
discriminator?: IOneOf.IDiscriminator; | ||
} | ||
export namespace IOneOf { | ||
export interface IDiscriminator { | ||
propertyName: string; | ||
mapping?: Record<string, string>; | ||
} | ||
} | ||
@@ -257,0 +264,0 @@ export interface __ISignificant<Type extends string> extends __IAttribute { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
383298
66
9674