@nestia/migrate 0.12.0 → 0.13.0-dev.20240411
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/MigrateApplication.d.ts +3 -4
- package/lib/MigrateApplication.js +5160 -947
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateControllerAnalyzer.js +2 -1
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateMethodAnalyzer.d.ts +2 -2
- package/lib/analyzers/MigrateMethodAnalyzer.js +60 -143
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +2 -2
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/factories/TypeLiteralFactory.d.ts +4 -0
- package/lib/factories/TypeLiteralFactory.js +35 -0
- package/lib/factories/TypeLiteralFactory.js.map +1 -0
- package/lib/internal/MigrateCommander.js +2 -2
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/module.d.ts +0 -6
- package/lib/module.js +0 -6
- package/lib/module.js.map +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiProgrammer.js +2 -2
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiSimulatationProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiStartProgrammer.js +8 -8
- package/lib/programmers/MigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/MigrateDtoProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateDtoProgrammer.js.map +1 -1
- package/lib/programmers/MigrateE2eFileProgrammer.d.ts +3 -3
- package/lib/programmers/MigrateE2eFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateE2eProgrammer.js +1 -1
- package/lib/programmers/MigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/MigrateImportProgrammer.d.ts +1 -1
- package/lib/programmers/MigrateImportProgrammer.js +2 -4
- package/lib/programmers/MigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestControllerProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestMethodProgrammer.d.ts +2 -2
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestProgrammer.js +2 -2
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.d.ts +2 -3
- package/lib/programmers/MigrateSchemaProgrammer.js +151 -28
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -1
- package/lib/structures/IMigrateDto.d.ts +2 -2
- package/lib/structures/IMigrateProgram.d.ts +3 -4
- package/lib/structures/IMigrateRoute.d.ts +6 -6
- package/lib/utils/OpenApiTypeChecker.d.ts +15 -0
- package/lib/utils/OpenApiTypeChecker.js +28 -0
- package/lib/utils/OpenApiTypeChecker.js.map +1 -0
- package/package.json +4 -3
- package/src/MigrateApplication.ts +81 -86
- package/src/analyzers/MigrateControllerAnalyzer.ts +7 -5
- package/src/analyzers/MigrateMethodAnalyzer.ts +103 -179
- package/src/bundles/NEST_TEMPLATE.ts +2 -2
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/factories/TypeLiteralFactory.ts +57 -0
- package/src/internal/MigrateCommander.ts +4 -4
- package/src/module.ts +0 -6
- package/src/programmers/MigrateApiFileProgrammer.ts +2 -2
- package/src/programmers/MigrateApiFunctionProgrammer.ts +3 -3
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +5 -5
- package/src/programmers/MigrateApiProgrammer.ts +4 -2
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +4 -4
- package/src/programmers/MigrateApiStartProgrammer.ts +8 -8
- package/src/programmers/MigrateDtoProgrammer.ts +5 -6
- package/src/programmers/MigrateE2eFileProgrammer.ts +4 -4
- package/src/programmers/MigrateE2eProgrammer.ts +3 -3
- package/src/programmers/MigrateImportProgrammer.ts +117 -121
- package/src/programmers/MigrateNestControllerProgrammer.ts +2 -2
- package/src/programmers/MigrateNestMethodProgrammer.ts +6 -7
- package/src/programmers/MigrateNestProgrammer.ts +2 -2
- package/src/programmers/MigrateSchemaProgrammer.ts +355 -263
- package/src/structures/IMigrateDto.ts +2 -2
- package/src/structures/IMigrateProgram.ts +4 -4
- package/src/structures/IMigrateRoute.ts +6 -6
- package/src/utils/OpenApiTypeChecker.ts +73 -0
- package/lib/structures/ISwagger.d.ts +0 -18
- package/lib/structures/ISwagger.js +0 -3
- package/lib/structures/ISwagger.js.map +0 -1
- package/lib/structures/ISwaggerComponents.d.ts +0 -12
- package/lib/structures/ISwaggerComponents.js +0 -3
- package/lib/structures/ISwaggerComponents.js.map +0 -1
- package/lib/structures/ISwaggerInfo.d.ts +0 -71
- package/lib/structures/ISwaggerInfo.js +0 -3
- package/lib/structures/ISwaggerInfo.js.map +0 -1
- package/lib/structures/ISwaggerRoute.d.ts +0 -15
- package/lib/structures/ISwaggerRoute.js +0 -3
- package/lib/structures/ISwaggerRoute.js.map +0 -1
- package/lib/structures/ISwaggerRouteBodyContent.d.ts +0 -14
- package/lib/structures/ISwaggerRouteBodyContent.js +0 -3
- package/lib/structures/ISwaggerRouteBodyContent.js.map +0 -1
- package/lib/structures/ISwaggerRouteHeader.d.ts +0 -0
- package/lib/structures/ISwaggerRouteHeader.js +0 -2
- package/lib/structures/ISwaggerRouteHeader.js.map +0 -1
- package/lib/structures/ISwaggerRouteParameter.d.ts +0 -13
- package/lib/structures/ISwaggerRouteParameter.js +0 -3
- package/lib/structures/ISwaggerRouteParameter.js.map +0 -1
- package/lib/structures/ISwaggerRouteRequestBody.d.ts +0 -11
- package/lib/structures/ISwaggerRouteRequestBody.js +0 -3
- package/lib/structures/ISwaggerRouteRequestBody.js.map +0 -1
- package/lib/structures/ISwaggerRouteResponse.d.ts +0 -10
- package/lib/structures/ISwaggerRouteResponse.js +0 -3
- package/lib/structures/ISwaggerRouteResponse.js.map +0 -1
- package/lib/structures/ISwaggerSchema.d.ts +0 -75
- package/lib/structures/ISwaggerSchema.js +0 -3
- package/lib/structures/ISwaggerSchema.js.map +0 -1
- package/lib/structures/ISwaggerSecurityScheme.d.ts +0 -40
- package/lib/structures/ISwaggerSecurityScheme.js +0 -3
- package/lib/structures/ISwaggerSecurityScheme.js.map +0 -1
- package/lib/structures/ISwaggerV20.d.ts +0 -8
- package/lib/structures/ISwaggerV20.js +0 -3
- package/lib/structures/ISwaggerV20.js.map +0 -1
- package/lib/structures/ISwaggerV31.d.ts +0 -9
- package/lib/structures/ISwaggerV31.js +0 -3
- package/lib/structures/ISwaggerV31.js.map +0 -1
- package/lib/utils/OpenApiConverter.d.ts +0 -5
- package/lib/utils/OpenApiConverter.js +0 -1568
- package/lib/utils/OpenApiConverter.js.map +0 -1
- package/lib/utils/SwaggerComponentsExplorer.d.ts +0 -9
- package/lib/utils/SwaggerComponentsExplorer.js +0 -29
- package/lib/utils/SwaggerComponentsExplorer.js.map +0 -1
- package/lib/utils/SwaggerTypeChecker.d.ts +0 -16
- package/lib/utils/SwaggerTypeChecker.js +0 -34
- package/lib/utils/SwaggerTypeChecker.js.map +0 -1
- package/src/structures/ISwagger.ts +0 -23
- package/src/structures/ISwaggerComponents.ts +0 -13
- package/src/structures/ISwaggerInfo.ts +0 -80
- package/src/structures/ISwaggerRoute.ts +0 -20
- package/src/structures/ISwaggerRouteBodyContent.ts +0 -15
- package/src/structures/ISwaggerRouteHeader.ts +0 -0
- package/src/structures/ISwaggerRouteParameter.ts +0 -14
- package/src/structures/ISwaggerRouteRequestBody.ts +0 -12
- package/src/structures/ISwaggerRouteResponse.ts +0 -11
- package/src/structures/ISwaggerSchema.ts +0 -90
- package/src/structures/ISwaggerSecurityScheme.ts +0 -47
- package/src/structures/ISwaggerV20.ts +0 -10
- package/src/structures/ISwaggerV31.ts +0 -10
- package/src/utils/OpenApiConverter.ts +0 -19
- package/src/utils/SwaggerComponentsExplorer.ts +0 -43
- package/src/utils/SwaggerTypeChecker.ts +0 -67
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"OpenApiConverter.js","sourceRoot":"","sources":["../../src/utils/OpenApiConverter.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA+C;AAC/C,kDAA0B;AAK1B,gEAA8E;AAE9E,IAAiB,gBAAgB,CAUhC;AAVD,WAAiB,gBAAgB;IAC/B,2EAA2E;IAC3E,gEAAgE;IAChE,mDAAmD;IACnD,KAAK;IAEQ,qBAAI,GAAG,CAAC,OAAoB,EAAY,EAAE;QACrD,MAAM,SAAS,GAAG,IAAI,qBAAa,CAAC,OAAO,CAAC,CAAC;QAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAAO,eAAK,CAAC,MAAM;kCAAZ,eAAK,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAW,SAAS,CAAC,OAAO,EAAc,EAAE;IACjE,CAAC,CAAC;AACJ,CAAC,EAVgB,gBAAgB,gCAAhB,gBAAgB,QAUhC"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "../module";
|
2
|
-
import { ISwaggerRouteParameter } from "../structures/ISwaggerRouteParameter";
|
3
|
-
import { ISwaggerRouteRequestBody } from "../structures/ISwaggerRouteRequestBody";
|
4
|
-
import { ISwaggerRouteResponse } from "../structures/ISwaggerRouteResponse";
|
5
|
-
export declare namespace SwaggerComponentsExplorer {
|
6
|
-
const getParameter: (components: ISwaggerComponents) => (schema: ISwaggerRouteParameter | ISwaggerRouteParameter.IReference) => ISwaggerRouteParameter | null;
|
7
|
-
const getRequestBody: (components: ISwaggerComponents) => (schema: ISwaggerRouteRequestBody | ISwaggerRouteRequestBody.IReference) => ISwaggerRouteRequestBody | null;
|
8
|
-
const getResponse: (components: ISwaggerComponents) => (schema: ISwaggerRouteResponse | ISwaggerRouteResponse.IReference) => ISwaggerRouteResponse | null;
|
9
|
-
}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SwaggerComponentsExplorer = void 0;
|
4
|
-
const SwaggerTypeChecker_1 = require("./SwaggerTypeChecker");
|
5
|
-
var SwaggerComponentsExplorer;
|
6
|
-
(function (SwaggerComponentsExplorer) {
|
7
|
-
SwaggerComponentsExplorer.getParameter = (components) => (schema) => {
|
8
|
-
var _a, _b;
|
9
|
-
return SwaggerTypeChecker_1.SwaggerTypeChecker.isReference(schema) &&
|
10
|
-
schema.$ref.startsWith("#/components/parameters/")
|
11
|
-
? (_b = (_a = components.parameters) === null || _a === void 0 ? void 0 : _a[schema.$ref.replace("#/components/parameters/", "")]) !== null && _b !== void 0 ? _b : null
|
12
|
-
: schema;
|
13
|
-
};
|
14
|
-
SwaggerComponentsExplorer.getRequestBody = (components) => (schema) => {
|
15
|
-
var _a, _b;
|
16
|
-
return SwaggerTypeChecker_1.SwaggerTypeChecker.isReference(schema) &&
|
17
|
-
schema.$ref.startsWith("#/components/requestBodies/")
|
18
|
-
? (_b = (_a = components.requestBodies) === null || _a === void 0 ? void 0 : _a[schema.$ref.replace("#/components/requestBodies/", "")]) !== null && _b !== void 0 ? _b : null
|
19
|
-
: schema;
|
20
|
-
};
|
21
|
-
SwaggerComponentsExplorer.getResponse = (components) => (schema) => {
|
22
|
-
var _a, _b;
|
23
|
-
return SwaggerTypeChecker_1.SwaggerTypeChecker.isReference(schema) &&
|
24
|
-
schema.$ref.startsWith("#/components/responses/")
|
25
|
-
? (_b = (_a = components.responses) === null || _a === void 0 ? void 0 : _a[schema.$ref.replace("#/components/responses/", "")]) !== null && _b !== void 0 ? _b : null
|
26
|
-
: schema;
|
27
|
-
};
|
28
|
-
})(SwaggerComponentsExplorer || (exports.SwaggerComponentsExplorer = SwaggerComponentsExplorer = {}));
|
29
|
-
//# sourceMappingURL=SwaggerComponentsExplorer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SwaggerComponentsExplorer.js","sourceRoot":"","sources":["../../src/utils/SwaggerComponentsExplorer.ts"],"names":[],"mappings":";;;AAIA,6DAA0D;AAE1D,IAAiB,yBAAyB,CAoCzC;AApCD,WAAiB,yBAAyB;IAC3B,sCAAY,GACvB,CAAC,UAA8B,EAAE,EAAE,CACnC,CACE,MAAkE,EACnC,EAAE;;QACjC,OAAA,uCAAkB,CAAC,WAAW,CAAC,MAAM,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC;YAChD,CAAC,CAAC,MAAA,MAAA,UAAU,CAAC,UAAU,0CACnB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CACpD,mCAAI,IAAI;YACX,CAAC,CAAE,MAAiC,CAAA;KAAA,CAAC;IAE9B,wCAAc,GACzB,CAAC,UAA8B,EAAE,EAAE,CACnC,CACE,MAAsE,EACrC,EAAE;;QACnC,OAAA,uCAAkB,CAAC,WAAW,CAAC,MAAM,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,6BAA6B,CAAC;YACnD,CAAC,CAAC,MAAA,MAAA,UAAU,CAAC,aAAa,0CACtB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CACvD,mCAAI,IAAI;YACX,CAAC,CAAE,MAAmC,CAAA;KAAA,CAAC;IAEhC,qCAAW,GACtB,CAAC,UAA8B,EAAE,EAAE,CACnC,CACE,MAAgE,EAClC,EAAE;;QAChC,OAAA,uCAAkB,CAAC,WAAW,CAAC,MAAM,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC;YAC/C,CAAC,CAAC,MAAA,MAAA,UAAU,CAAC,SAAS,0CAClB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CACnD,mCAAI,IAAI;YACX,CAAC,CAAE,MAAgC,CAAA;KAAA,CAAC;AAC5C,CAAC,EApCgB,yBAAyB,yCAAzB,yBAAyB,QAoCzC"}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
2
|
-
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
3
|
-
export declare namespace SwaggerTypeChecker {
|
4
|
-
const isAnyOf: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IAnyOf;
|
5
|
-
const isOneOf: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IOneOf;
|
6
|
-
const isNullOnly: (schema: ISwaggerSchema) => schema is ISwaggerSchema.INullOnly;
|
7
|
-
const isBoolean: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IBoolean;
|
8
|
-
const isInteger: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IInteger;
|
9
|
-
const isNumber: (schema: ISwaggerSchema) => schema is ISwaggerSchema.INumber;
|
10
|
-
const isString: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IString;
|
11
|
-
const isArray: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IArray;
|
12
|
-
const isObject: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IObject;
|
13
|
-
const isReference: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IReference;
|
14
|
-
const isUnknown: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IUnknown;
|
15
|
-
const isNullable: (components: ISwaggerComponents) => (schema: ISwaggerSchema) => boolean;
|
16
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SwaggerTypeChecker = void 0;
|
4
|
-
var SwaggerTypeChecker;
|
5
|
-
(function (SwaggerTypeChecker) {
|
6
|
-
SwaggerTypeChecker.isAnyOf = (schema) => schema.anyOf !== undefined;
|
7
|
-
SwaggerTypeChecker.isOneOf = (schema) => schema.oneOf !== undefined;
|
8
|
-
SwaggerTypeChecker.isNullOnly = (schema) => schema.type === "null";
|
9
|
-
SwaggerTypeChecker.isBoolean = (schema) => schema.type === "boolean";
|
10
|
-
SwaggerTypeChecker.isInteger = (schema) => schema.type === "integer";
|
11
|
-
SwaggerTypeChecker.isNumber = (schema) => schema.type === "number";
|
12
|
-
SwaggerTypeChecker.isString = (schema) => schema.type === "string";
|
13
|
-
SwaggerTypeChecker.isArray = (schema) => schema.type === "array";
|
14
|
-
SwaggerTypeChecker.isObject = (schema) => schema.type === "object";
|
15
|
-
SwaggerTypeChecker.isReference = (schema) => schema.$ref !== undefined;
|
16
|
-
SwaggerTypeChecker.isUnknown = (schema) => schema.type === undefined &&
|
17
|
-
!SwaggerTypeChecker.isAnyOf(schema) &&
|
18
|
-
!SwaggerTypeChecker.isOneOf(schema) &&
|
19
|
-
!SwaggerTypeChecker.isReference(schema);
|
20
|
-
SwaggerTypeChecker.isNullable = (components) => (schema) => {
|
21
|
-
var _a;
|
22
|
-
if (SwaggerTypeChecker.isAnyOf(schema))
|
23
|
-
return schema.anyOf.some(SwaggerTypeChecker.isNullable(components));
|
24
|
-
else if (SwaggerTypeChecker.isOneOf(schema))
|
25
|
-
return schema.oneOf.some(SwaggerTypeChecker.isNullable(components));
|
26
|
-
else if (SwaggerTypeChecker.isReference(schema)) {
|
27
|
-
const $id = schema.$ref.replace("#/components/schemas/", "");
|
28
|
-
const target = ((_a = components.schemas) !== null && _a !== void 0 ? _a : {})[$id];
|
29
|
-
return target === undefined ? false : SwaggerTypeChecker.isNullable(components)(target);
|
30
|
-
}
|
31
|
-
return schema.nullable === true;
|
32
|
-
};
|
33
|
-
})(SwaggerTypeChecker || (exports.SwaggerTypeChecker = SwaggerTypeChecker = {}));
|
34
|
-
//# sourceMappingURL=SwaggerTypeChecker.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SwaggerTypeChecker.js","sourceRoot":"","sources":["../../src/utils/SwaggerTypeChecker.ts"],"names":[],"mappings":";;;AAGA,IAAiB,kBAAkB,CA+DlC;AA/DD,WAAiB,kBAAkB;IACpB,0BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,0BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,6BAAU,GAAG,CACxB,MAAsB,EACc,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,MAAM,CAAC;IAE5D,4BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,4BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,2BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,2BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,0BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,CAAC;IAE1D,2BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,8BAAW,GAAG,CACzB,MAAsB,EACe,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAEhE,4BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CACpC,MAAc,CAAC,IAAI,KAAK,SAAS;QAClC,CAAC,mBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,mBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,mBAAA,WAAW,CAAC,MAAM,CAAC,CAAC;IAEV,6BAAU,GACrB,CAAC,UAA8B,EAAE,EAAE,CACnC,CAAC,MAAsB,EAAW,EAAE;;QAClC,IAAI,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;YACpC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;aAC9C,IAAI,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;YACzC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;aAC9C,IAAI,kBAAkB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,CAAC,MAAA,UAAU,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;QACvE,CAAC;QACD,OAAQ,MAAiC,CAAC,QAAQ,KAAK,IAAI,CAAC;IAC9D,CAAC,CAAC;AACN,CAAC,EA/DgB,kBAAkB,kCAAlB,kBAAkB,QA+DlC"}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "./ISwaggerComponents";
|
2
|
-
import { ISwaggerInfo } from "./ISwaggerInfo";
|
3
|
-
import { ISwaggerRoute } from "./ISwaggerRoute";
|
4
|
-
|
5
|
-
export interface ISwagger {
|
6
|
-
openapi: `3.0.${number}`;
|
7
|
-
info: ISwaggerInfo;
|
8
|
-
servers: ISwagger.IServer[];
|
9
|
-
|
10
|
-
components: ISwaggerComponents;
|
11
|
-
paths: Record<string, ISwagger.IPath>;
|
12
|
-
security?: Record<string, string[]>[];
|
13
|
-
}
|
14
|
-
export namespace ISwagger {
|
15
|
-
export interface IServer {
|
16
|
-
url: string;
|
17
|
-
description?: string;
|
18
|
-
}
|
19
|
-
export type IPath = Record<
|
20
|
-
"get" | "post" | "patch" | "put" | "delete",
|
21
|
-
ISwaggerRoute | undefined
|
22
|
-
>;
|
23
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
2
|
-
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
3
|
-
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
4
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
5
|
-
import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
|
6
|
-
|
7
|
-
export interface ISwaggerComponents {
|
8
|
-
parameters?: Record<string, ISwaggerRouteParameter>;
|
9
|
-
requestBodies?: Record<string, ISwaggerRouteRequestBody>;
|
10
|
-
responses?: Record<string, ISwaggerRouteResponse>;
|
11
|
-
schemas?: Record<string, ISwaggerSchema>;
|
12
|
-
securitySchemes?: Record<string, ISwaggerSecurityScheme>;
|
13
|
-
}
|
@@ -1,80 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Information about the API.
|
3
|
-
*
|
4
|
-
* @author Samchon
|
5
|
-
*/
|
6
|
-
export interface ISwaggerInfo {
|
7
|
-
/**
|
8
|
-
* The title of the API.
|
9
|
-
*/
|
10
|
-
title: string;
|
11
|
-
|
12
|
-
/**
|
13
|
-
* A short description of the API.
|
14
|
-
*/
|
15
|
-
description?: string;
|
16
|
-
|
17
|
-
/**
|
18
|
-
* A URL to the Terms of Service for the API.
|
19
|
-
*
|
20
|
-
* @format uri
|
21
|
-
*/
|
22
|
-
termsOfService?: string;
|
23
|
-
|
24
|
-
/**
|
25
|
-
* The contact information for the exposed API.
|
26
|
-
*/
|
27
|
-
contact?: ISwaggerInfo.IContact;
|
28
|
-
|
29
|
-
/**
|
30
|
-
* The license information for the exposed API.
|
31
|
-
*/
|
32
|
-
license?: ISwaggerInfo.ILicense;
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Version of the API.
|
36
|
-
*/
|
37
|
-
version: string;
|
38
|
-
}
|
39
|
-
export namespace ISwaggerInfo {
|
40
|
-
/**
|
41
|
-
* Contact information for the exposed API.
|
42
|
-
*/
|
43
|
-
export interface IContact {
|
44
|
-
/**
|
45
|
-
* The identifying name of the contact person/organization.
|
46
|
-
*/
|
47
|
-
name?: string;
|
48
|
-
|
49
|
-
/**
|
50
|
-
* The URL pointing to the contact information.
|
51
|
-
*
|
52
|
-
* @format uri
|
53
|
-
*/
|
54
|
-
url?: string;
|
55
|
-
|
56
|
-
/**
|
57
|
-
* The email address of the contact person/organization.
|
58
|
-
*
|
59
|
-
* @format email
|
60
|
-
*/
|
61
|
-
email?: string;
|
62
|
-
}
|
63
|
-
|
64
|
-
/**
|
65
|
-
* License information for the exposed API.
|
66
|
-
*/
|
67
|
-
export interface ILicense {
|
68
|
-
/**
|
69
|
-
* The license name used for the API.
|
70
|
-
*/
|
71
|
-
name: string;
|
72
|
-
|
73
|
-
/**
|
74
|
-
* A URL to the license used for the API.
|
75
|
-
*
|
76
|
-
* @format uri
|
77
|
-
*/
|
78
|
-
url?: string;
|
79
|
-
}
|
80
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
|
2
|
-
|
3
|
-
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
4
|
-
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
5
|
-
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
6
|
-
|
7
|
-
export interface ISwaggerRoute {
|
8
|
-
parameters?: (ISwaggerRouteParameter | ISwaggerRouteParameter.IReference)[];
|
9
|
-
requestBody?: ISwaggerRouteRequestBody;
|
10
|
-
responses?: Record<
|
11
|
-
string,
|
12
|
-
ISwaggerRouteResponse | ISwaggerRouteResponse.IReference
|
13
|
-
>;
|
14
|
-
summary?: string;
|
15
|
-
description?: string;
|
16
|
-
deprecated?: boolean;
|
17
|
-
security?: Record<string, string[]>[];
|
18
|
-
tags?: string[];
|
19
|
-
"x-nestia-jsDocTags"?: IJsDocTagInfo[];
|
20
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
2
|
-
|
3
|
-
export interface ISwaggerRouteBodyContent {
|
4
|
-
"text/plain"?: ISwaggerRouteBodyContent.IMediaType;
|
5
|
-
"application/json"?: ISwaggerRouteBodyContent.IMediaType;
|
6
|
-
"application/x-www-form-urlencoded"?: ISwaggerRouteBodyContent.IMediaType;
|
7
|
-
"multipart/form-data"?: ISwaggerRouteBodyContent.IMediaType;
|
8
|
-
"*/*"?: ISwaggerRouteBodyContent.IMediaType;
|
9
|
-
}
|
10
|
-
export namespace ISwaggerRouteBodyContent {
|
11
|
-
export interface IMediaType {
|
12
|
-
schema?: ISwaggerSchema;
|
13
|
-
"x-nestia-encrypted"?: boolean;
|
14
|
-
}
|
15
|
-
}
|
File without changes
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ISwaggerSchema } from "./ISwaggerSchema";
|
2
|
-
|
3
|
-
export interface ISwaggerRouteParameter {
|
4
|
-
name?: string;
|
5
|
-
in: "path" | "query" | "header" | "cookie";
|
6
|
-
schema: ISwaggerSchema;
|
7
|
-
required?: boolean;
|
8
|
-
description?: string;
|
9
|
-
}
|
10
|
-
export namespace ISwaggerRouteParameter {
|
11
|
-
export interface IReference {
|
12
|
-
$ref: `#/components/parameters/${string}`;
|
13
|
-
}
|
14
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { ISwaggerRouteBodyContent } from "./ISwaggerRouteBodyContent";
|
2
|
-
|
3
|
-
export interface ISwaggerRouteRequestBody {
|
4
|
-
description?: string;
|
5
|
-
required?: boolean;
|
6
|
-
content?: ISwaggerRouteBodyContent;
|
7
|
-
}
|
8
|
-
export namespace ISwaggerRouteRequestBody {
|
9
|
-
export interface IReference {
|
10
|
-
$ref: `#/components/requestBodies/${string}`;
|
11
|
-
}
|
12
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { ISwaggerRouteBodyContent } from "./ISwaggerRouteBodyContent";
|
2
|
-
|
3
|
-
export interface ISwaggerRouteResponse {
|
4
|
-
description?: string;
|
5
|
-
content?: ISwaggerRouteBodyContent;
|
6
|
-
}
|
7
|
-
export namespace ISwaggerRouteResponse {
|
8
|
-
export interface IReference {
|
9
|
-
$ref: `#/components/responses/${string}`;
|
10
|
-
}
|
11
|
-
}
|
@@ -1,90 +0,0 @@
|
|
1
|
-
export type ISwaggerSchema =
|
2
|
-
| ISwaggerSchema.IUnknown
|
3
|
-
| ISwaggerSchema.INullOnly
|
4
|
-
| ISwaggerSchema.IAnyOf
|
5
|
-
| ISwaggerSchema.IOneOf
|
6
|
-
| ISwaggerSchema.IBoolean
|
7
|
-
| ISwaggerSchema.IInteger
|
8
|
-
| ISwaggerSchema.INumber
|
9
|
-
| ISwaggerSchema.IString
|
10
|
-
| ISwaggerSchema.IArray
|
11
|
-
| ISwaggerSchema.IObject
|
12
|
-
| ISwaggerSchema.IReference;
|
13
|
-
export namespace ISwaggerSchema {
|
14
|
-
export interface IUnknown extends IAttribute {
|
15
|
-
type?: undefined;
|
16
|
-
}
|
17
|
-
export interface INullOnly extends IAttribute {
|
18
|
-
type: "null";
|
19
|
-
}
|
20
|
-
|
21
|
-
export interface IAnyOf extends IAttribute {
|
22
|
-
anyOf: ISwaggerSchema[];
|
23
|
-
}
|
24
|
-
export interface IOneOf extends IAttribute {
|
25
|
-
oneOf: ISwaggerSchema[];
|
26
|
-
}
|
27
|
-
|
28
|
-
export interface IBoolean extends ISignificant<"boolean"> {
|
29
|
-
default?: boolean;
|
30
|
-
enum?: boolean[];
|
31
|
-
}
|
32
|
-
export interface IInteger extends ISignificant<"integer"> {
|
33
|
-
/** @type int */ default?: number;
|
34
|
-
/** @type int */ enum?: number[];
|
35
|
-
/** @type int */ minimum?: number;
|
36
|
-
/** @type int */ maximum?: number;
|
37
|
-
/** @type int */ exclusiveMinimum?: boolean;
|
38
|
-
/** @type int */ exclusiveMaximum?: boolean;
|
39
|
-
/** @type uint */ multipleOf?: number;
|
40
|
-
}
|
41
|
-
export interface INumber extends ISignificant<"number"> {
|
42
|
-
default?: number;
|
43
|
-
enum?: number[];
|
44
|
-
minimum?: number;
|
45
|
-
maximum?: number;
|
46
|
-
exclusiveMinimum?: boolean;
|
47
|
-
exclusiveMaximum?: boolean;
|
48
|
-
multipleOf?: number;
|
49
|
-
}
|
50
|
-
export interface IString extends ISignificant<"string"> {
|
51
|
-
default?: string;
|
52
|
-
enum?: string[];
|
53
|
-
format?: string;
|
54
|
-
pattern?: string;
|
55
|
-
/** @type uint */ minLength?: number;
|
56
|
-
/** @type uint */ maxLength?: number;
|
57
|
-
}
|
58
|
-
|
59
|
-
export interface IArray extends ISignificant<"array"> {
|
60
|
-
items: ISwaggerSchema;
|
61
|
-
/** @type uint */ minItems?: number;
|
62
|
-
/** @type uint */ maxItems?: number;
|
63
|
-
"x-typia-tuple"?: ITuple;
|
64
|
-
}
|
65
|
-
export interface ITuple extends ISignificant<"array"> {
|
66
|
-
items: ISwaggerSchema[];
|
67
|
-
}
|
68
|
-
export interface IObject extends ISignificant<"object"> {
|
69
|
-
properties?: Record<string, ISwaggerSchema>;
|
70
|
-
required?: string[];
|
71
|
-
additionalProperties?: ISwaggerSchema | boolean;
|
72
|
-
"x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
|
73
|
-
}
|
74
|
-
|
75
|
-
export interface IReference extends IAttribute {
|
76
|
-
$ref: string;
|
77
|
-
}
|
78
|
-
|
79
|
-
interface ISignificant<Type extends string> extends IAttribute {
|
80
|
-
type: Type;
|
81
|
-
nullable?: boolean;
|
82
|
-
}
|
83
|
-
interface IAttribute {
|
84
|
-
title?: string;
|
85
|
-
description?: string;
|
86
|
-
deprecated?: boolean;
|
87
|
-
"x-typia-optional"?: boolean;
|
88
|
-
"x-typia-rest"?: boolean;
|
89
|
-
}
|
90
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
export type ISwaggerSecurityScheme =
|
2
|
-
| ISwaggerSecurityScheme.IHttpBasic
|
3
|
-
| ISwaggerSecurityScheme.IHttpBearer
|
4
|
-
| ISwaggerSecurityScheme.IApiKey
|
5
|
-
| ISwaggerSecurityScheme.IOpenId
|
6
|
-
| ISwaggerSecurityScheme.IOAuth2;
|
7
|
-
export namespace ISwaggerSecurityScheme {
|
8
|
-
export interface IHttpBasic {
|
9
|
-
type: "http";
|
10
|
-
scheme: "basic";
|
11
|
-
}
|
12
|
-
export interface IHttpBearer {
|
13
|
-
type: "http";
|
14
|
-
scheme: "bearer";
|
15
|
-
bearerFormat?: string;
|
16
|
-
}
|
17
|
-
export interface IApiKey {
|
18
|
-
type: "apiKey";
|
19
|
-
in?: "header" | "query" | "cookie";
|
20
|
-
name?: string;
|
21
|
-
}
|
22
|
-
|
23
|
-
export interface IOpenId {
|
24
|
-
type: "openIdConnect";
|
25
|
-
openIdConnectUrl: string;
|
26
|
-
}
|
27
|
-
|
28
|
-
export interface IOAuth2 {
|
29
|
-
type: "oauth2";
|
30
|
-
flows: IOAuth2.IFlowSet;
|
31
|
-
description?: string;
|
32
|
-
}
|
33
|
-
export namespace IOAuth2 {
|
34
|
-
export interface IFlowSet {
|
35
|
-
authorizationCode?: IFlow;
|
36
|
-
implicit?: Omit<IFlow, "tokenUrl">;
|
37
|
-
password?: Omit<IFlow, "authorizationUrl">;
|
38
|
-
clientCredentials?: Omit<IFlow, "authorizationUrl">;
|
39
|
-
}
|
40
|
-
export interface IFlow {
|
41
|
-
authorizationUrl: string;
|
42
|
-
tokenUrl?: string;
|
43
|
-
refreshUrl?: string;
|
44
|
-
scopes?: Record<string, string>;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
// import V2_0Converter from "swagger2openapi";
|
2
|
-
import typia from "typia";
|
3
|
-
|
4
|
-
import { ISwagger } from "../structures/ISwagger";
|
5
|
-
// import { ISwaggerV20 } from "../structures/ISwaggerV20";
|
6
|
-
import { ISwaggerV31 } from "../structures/ISwaggerV31";
|
7
|
-
import { Converter as V3_1Converter } from "./openapi-down-convert/converter";
|
8
|
-
|
9
|
-
export namespace OpenApiConverter {
|
10
|
-
// export const v2_0 = async (swagger: ISwaggerV20): Promise<ISwagger> => {
|
11
|
-
// const output = await V2_0Converter.convertObj(swagger, {});
|
12
|
-
// return typia.assert<ISwagger>(output.openapi);
|
13
|
-
// };
|
14
|
-
|
15
|
-
export const v3_1 = (swagger: ISwaggerV31): ISwagger => {
|
16
|
-
const converter = new V3_1Converter(swagger);
|
17
|
-
return typia.assert<ISwagger>(converter.convert() as ISwagger);
|
18
|
-
};
|
19
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "../module";
|
2
|
-
import { ISwaggerRouteParameter } from "../structures/ISwaggerRouteParameter";
|
3
|
-
import { ISwaggerRouteRequestBody } from "../structures/ISwaggerRouteRequestBody";
|
4
|
-
import { ISwaggerRouteResponse } from "../structures/ISwaggerRouteResponse";
|
5
|
-
import { SwaggerTypeChecker } from "./SwaggerTypeChecker";
|
6
|
-
|
7
|
-
export namespace SwaggerComponentsExplorer {
|
8
|
-
export const getParameter =
|
9
|
-
(components: ISwaggerComponents) =>
|
10
|
-
(
|
11
|
-
schema: ISwaggerRouteParameter | ISwaggerRouteParameter.IReference,
|
12
|
-
): ISwaggerRouteParameter | null =>
|
13
|
-
SwaggerTypeChecker.isReference(schema) &&
|
14
|
-
schema.$ref.startsWith("#/components/parameters/")
|
15
|
-
? components.parameters?.[
|
16
|
-
schema.$ref.replace("#/components/parameters/", "")
|
17
|
-
] ?? null
|
18
|
-
: (schema as ISwaggerRouteParameter);
|
19
|
-
|
20
|
-
export const getRequestBody =
|
21
|
-
(components: ISwaggerComponents) =>
|
22
|
-
(
|
23
|
-
schema: ISwaggerRouteRequestBody | ISwaggerRouteRequestBody.IReference,
|
24
|
-
): ISwaggerRouteRequestBody | null =>
|
25
|
-
SwaggerTypeChecker.isReference(schema) &&
|
26
|
-
schema.$ref.startsWith("#/components/requestBodies/")
|
27
|
-
? components.requestBodies?.[
|
28
|
-
schema.$ref.replace("#/components/requestBodies/", "")
|
29
|
-
] ?? null
|
30
|
-
: (schema as ISwaggerRouteRequestBody);
|
31
|
-
|
32
|
-
export const getResponse =
|
33
|
-
(components: ISwaggerComponents) =>
|
34
|
-
(
|
35
|
-
schema: ISwaggerRouteResponse | ISwaggerRouteResponse.IReference,
|
36
|
-
): ISwaggerRouteResponse | null =>
|
37
|
-
SwaggerTypeChecker.isReference(schema) &&
|
38
|
-
schema.$ref.startsWith("#/components/responses/")
|
39
|
-
? components.responses?.[
|
40
|
-
schema.$ref.replace("#/components/responses/", "")
|
41
|
-
] ?? null
|
42
|
-
: (schema as ISwaggerRouteResponse);
|
43
|
-
}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
2
|
-
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
3
|
-
|
4
|
-
export namespace SwaggerTypeChecker {
|
5
|
-
export const isAnyOf = (
|
6
|
-
schema: ISwaggerSchema,
|
7
|
-
): schema is ISwaggerSchema.IAnyOf => (schema as any).anyOf !== undefined;
|
8
|
-
|
9
|
-
export const isOneOf = (
|
10
|
-
schema: ISwaggerSchema,
|
11
|
-
): schema is ISwaggerSchema.IOneOf => (schema as any).oneOf !== undefined;
|
12
|
-
|
13
|
-
export const isNullOnly = (
|
14
|
-
schema: ISwaggerSchema,
|
15
|
-
): schema is ISwaggerSchema.INullOnly => (schema as any).type === "null";
|
16
|
-
|
17
|
-
export const isBoolean = (
|
18
|
-
schema: ISwaggerSchema,
|
19
|
-
): schema is ISwaggerSchema.IBoolean => (schema as any).type === "boolean";
|
20
|
-
|
21
|
-
export const isInteger = (
|
22
|
-
schema: ISwaggerSchema,
|
23
|
-
): schema is ISwaggerSchema.IInteger => (schema as any).type === "integer";
|
24
|
-
|
25
|
-
export const isNumber = (
|
26
|
-
schema: ISwaggerSchema,
|
27
|
-
): schema is ISwaggerSchema.INumber => (schema as any).type === "number";
|
28
|
-
|
29
|
-
export const isString = (
|
30
|
-
schema: ISwaggerSchema,
|
31
|
-
): schema is ISwaggerSchema.IString => (schema as any).type === "string";
|
32
|
-
|
33
|
-
export const isArray = (
|
34
|
-
schema: ISwaggerSchema,
|
35
|
-
): schema is ISwaggerSchema.IArray => (schema as any).type === "array";
|
36
|
-
|
37
|
-
export const isObject = (
|
38
|
-
schema: ISwaggerSchema,
|
39
|
-
): schema is ISwaggerSchema.IObject => (schema as any).type === "object";
|
40
|
-
|
41
|
-
export const isReference = (
|
42
|
-
schema: ISwaggerSchema,
|
43
|
-
): schema is ISwaggerSchema.IReference => (schema as any).$ref !== undefined;
|
44
|
-
|
45
|
-
export const isUnknown = (
|
46
|
-
schema: ISwaggerSchema,
|
47
|
-
): schema is ISwaggerSchema.IUnknown =>
|
48
|
-
(schema as any).type === undefined &&
|
49
|
-
!isAnyOf(schema) &&
|
50
|
-
!isOneOf(schema) &&
|
51
|
-
!isReference(schema);
|
52
|
-
|
53
|
-
export const isNullable =
|
54
|
-
(components: ISwaggerComponents) =>
|
55
|
-
(schema: ISwaggerSchema): boolean => {
|
56
|
-
if (SwaggerTypeChecker.isAnyOf(schema))
|
57
|
-
return schema.anyOf.some(isNullable(components));
|
58
|
-
else if (SwaggerTypeChecker.isOneOf(schema))
|
59
|
-
return schema.oneOf.some(isNullable(components));
|
60
|
-
else if (SwaggerTypeChecker.isReference(schema)) {
|
61
|
-
const $id = schema.$ref.replace("#/components/schemas/", "");
|
62
|
-
const target = (components.schemas ?? {})[$id];
|
63
|
-
return target === undefined ? false : isNullable(components)(target);
|
64
|
-
}
|
65
|
-
return (schema as ISwaggerSchema.IString).nullable === true;
|
66
|
-
};
|
67
|
-
}
|