@goast/core 0.6.0 → 0.7.0-beta.2
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/README.md +0 -4
- package/dist/mod.d.ts +31 -0
- package/{script → dist}/src/ast/node.d.ts +3 -4
- package/{esm → dist}/src/ast/node.js +3 -9
- package/{esm → dist}/src/codegen/config.d.ts +2 -3
- package/{script → dist}/src/codegen/endpoints-generator.d.ts +4 -5
- package/{esm → dist}/src/codegen/endpoints-generator.js +1 -1
- package/{script → dist}/src/codegen/generator.d.ts +7 -8
- package/{esm → dist}/src/codegen/generator.js +4 -21
- package/{esm → dist}/src/codegen/internal-utils.d.ts +0 -1
- package/{esm → dist}/src/codegen/internal-utils.js +0 -1
- package/{script → dist}/src/codegen/schemas-generator.d.ts +4 -5
- package/{esm → dist}/src/codegen/schemas-generator.js +1 -2
- package/{esm → dist}/src/codegen/services-generator.d.ts +4 -5
- package/{esm → dist}/src/codegen/services-generator.js +1 -1
- package/{script → dist}/src/codegen/types.d.ts +3 -4
- package/dist/src/collect/collector.d.ts +4 -0
- package/{esm → dist}/src/collect/collector.js +6 -8
- package/{esm → dist}/src/collect/helpers.d.ts +2 -3
- package/{script → dist}/src/collect/types.d.ts +2 -3
- package/{esm → dist}/src/internal-utils.d.ts +0 -1
- package/dist/src/parse/deref-proxy.d.ts +3 -0
- package/{esm → dist}/src/parse/deref-proxy.js +7 -21
- package/{esm → dist}/src/parse/openapi-types.d.ts +0 -1
- package/{esm → dist}/src/parse/parser.d.ts +3 -4
- package/{esm → dist}/src/parse/parser.js +7 -20
- package/{script → dist}/src/parse/types.d.ts +3 -4
- package/{script → dist}/src/transform/api-types.d.ts +3 -4
- package/{esm → dist}/src/transform/helpers.d.ts +4 -5
- package/{esm → dist}/src/transform/helpers.js +5 -15
- package/dist/src/transform/transform-document.d.ts +4 -0
- package/{esm → dist}/src/transform/transform-document.js +2 -4
- package/{esm → dist}/src/transform/transform-endpoint.d.ts +3 -4
- package/{esm → dist}/src/transform/transform-endpoint.js +10 -17
- package/dist/src/transform/transform-schema.d.ts +5 -0
- package/{esm → dist}/src/transform/transform-schema.js +8 -12
- package/dist/src/transform/transformer.d.ts +4 -0
- package/{esm → dist}/src/transform/types.d.ts +4 -5
- package/{script → dist}/src/utils/action-provider.d.ts +2 -3
- package/{esm → dist}/src/utils/action-provider.js +3 -7
- package/{esm → dist}/src/utils/api-data.utils.d.ts +1 -2
- package/{esm → dist}/src/utils/array.utils.d.ts +0 -1
- package/{script → dist}/src/utils/asset-manager.d.ts +0 -1
- package/{esm → dist}/src/utils/asset-manager.js +2 -8
- package/{esm → dist}/src/utils/class.utils.d.ts +0 -1
- package/{esm → dist}/src/utils/class.utils.js +0 -1
- package/{script → dist}/src/utils/common.utils.d.ts +1 -2
- package/{esm → dist}/src/utils/condition.d.ts +0 -1
- package/dist/src/utils/endpoint.utils.d.ts +2 -0
- package/{esm → dist}/src/utils/error.utils.d.ts +0 -1
- package/{esm → dist}/src/utils/factory.d.ts +2 -3
- package/{esm → dist}/src/utils/factory.js +3 -7
- package/{esm → dist}/src/utils/file-system.utils.d.ts +2 -3
- package/{esm → dist}/src/utils/generator.utils.d.ts +0 -1
- package/{esm → dist}/src/utils/object.utils.d.ts +0 -1
- package/{esm → dist}/src/utils/object.utils.js +2 -11
- package/dist/src/utils/schema-factory.d.ts +41 -0
- package/dist/src/utils/schema-factory.js +132 -0
- package/{esm → dist}/src/utils/schema.utils.d.ts +2 -3
- package/{esm → dist}/src/utils/schema.utils.js +1 -5
- package/{esm → dist}/src/utils/source-builder.d.ts +5 -6
- package/{esm → dist}/src/utils/source-builder.js +19 -54
- package/{script → dist}/src/utils/string-builder/options.d.ts +0 -1
- package/{script → dist}/src/utils/string-builder/string-builder.d.ts +2 -3
- package/{esm → dist}/src/utils/string-builder/string-builder.js +2 -12
- package/{esm → dist}/src/utils/string-builder/utils.d.ts +2 -3
- package/{esm → dist}/src/utils/string-builder/utils.js +4 -6
- package/{script → dist}/src/utils/string.utils.d.ts +2 -3
- package/{esm → dist}/src/utils/string.utils.js +9 -15
- package/{esm → dist}/src/utils/string.utils.types.d.ts +0 -1
- package/{esm → dist}/src/utils/type.utils.d.ts +0 -1
- package/{script → dist}/src/utils/yaml-info.d.ts +0 -1
- package/{esm → dist}/src/utils/yaml-info.js +9 -6
- package/package.json +25 -16
- package/esm/_dnt.shims.d.ts +0 -11
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -66
- package/esm/mod.d.ts +0 -32
- package/esm/mod.d.ts.map +0 -1
- package/esm/package.json +0 -3
- package/esm/src/ast/node.d.ts +0 -17
- package/esm/src/ast/node.d.ts.map +0 -1
- package/esm/src/codegen/config.d.ts.map +0 -1
- package/esm/src/codegen/endpoints-generator.d.ts +0 -18
- package/esm/src/codegen/endpoints-generator.d.ts.map +0 -1
- package/esm/src/codegen/generator.d.ts +0 -39
- package/esm/src/codegen/generator.d.ts.map +0 -1
- package/esm/src/codegen/internal-utils.d.ts.map +0 -1
- package/esm/src/codegen/schemas-generator.d.ts +0 -19
- package/esm/src/codegen/schemas-generator.d.ts.map +0 -1
- package/esm/src/codegen/services-generator.d.ts.map +0 -1
- package/esm/src/codegen/types.d.ts +0 -19
- package/esm/src/codegen/types.d.ts.map +0 -1
- package/esm/src/collect/collector.d.ts +0 -5
- package/esm/src/collect/collector.d.ts.map +0 -1
- package/esm/src/collect/helpers.d.ts.map +0 -1
- package/esm/src/collect/types.d.ts +0 -14
- package/esm/src/collect/types.d.ts.map +0 -1
- package/esm/src/internal-utils.d.ts.map +0 -1
- package/esm/src/parse/deref-proxy.d.ts +0 -4
- package/esm/src/parse/deref-proxy.d.ts.map +0 -1
- package/esm/src/parse/openapi-types.d.ts.map +0 -1
- package/esm/src/parse/parser.d.ts.map +0 -1
- package/esm/src/parse/types.d.ts +0 -28
- package/esm/src/parse/types.d.ts.map +0 -1
- package/esm/src/transform/api-types.d.ts +0 -211
- package/esm/src/transform/api-types.d.ts.map +0 -1
- package/esm/src/transform/helpers.d.ts.map +0 -1
- package/esm/src/transform/transform-document.d.ts +0 -5
- package/esm/src/transform/transform-document.d.ts.map +0 -1
- package/esm/src/transform/transform-endpoint.d.ts.map +0 -1
- package/esm/src/transform/transform-schema.d.ts +0 -6
- package/esm/src/transform/transform-schema.d.ts.map +0 -1
- package/esm/src/transform/transformer.d.ts +0 -5
- package/esm/src/transform/transformer.d.ts.map +0 -1
- package/esm/src/transform/types.d.ts.map +0 -1
- package/esm/src/utils/action-provider.d.ts +0 -29
- package/esm/src/utils/action-provider.d.ts.map +0 -1
- package/esm/src/utils/api-data.utils.d.ts.map +0 -1
- package/esm/src/utils/array.utils.d.ts.map +0 -1
- package/esm/src/utils/asset-manager.d.ts +0 -9
- package/esm/src/utils/asset-manager.d.ts.map +0 -1
- package/esm/src/utils/class.utils.d.ts.map +0 -1
- package/esm/src/utils/common.utils.d.ts +0 -16
- package/esm/src/utils/common.utils.d.ts.map +0 -1
- package/esm/src/utils/condition.d.ts.map +0 -1
- package/esm/src/utils/endpoint.utils.d.ts +0 -3
- package/esm/src/utils/endpoint.utils.d.ts.map +0 -1
- package/esm/src/utils/error.utils.d.ts.map +0 -1
- package/esm/src/utils/factory.d.ts.map +0 -1
- package/esm/src/utils/file-system.utils.d.ts.map +0 -1
- package/esm/src/utils/generator.utils.d.ts.map +0 -1
- package/esm/src/utils/object.utils.d.ts.map +0 -1
- package/esm/src/utils/schema.utils.d.ts.map +0 -1
- package/esm/src/utils/source-builder.d.ts.map +0 -1
- package/esm/src/utils/string-builder/options.d.ts +0 -15
- package/esm/src/utils/string-builder/options.d.ts.map +0 -1
- package/esm/src/utils/string-builder/string-builder.d.ts +0 -73
- package/esm/src/utils/string-builder/string-builder.d.ts.map +0 -1
- package/esm/src/utils/string-builder/utils.d.ts.map +0 -1
- package/esm/src/utils/string.utils.d.ts +0 -149
- package/esm/src/utils/string.utils.d.ts.map +0 -1
- package/esm/src/utils/string.utils.types.d.ts.map +0 -1
- package/esm/src/utils/type.utils.d.ts.map +0 -1
- package/esm/src/utils/yaml-info.d.ts +0 -13
- package/esm/src/utils/yaml-info.d.ts.map +0 -1
- package/script/_dnt.shims.d.ts +0 -11
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -75
- package/script/mod.d.ts +0 -32
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -36
- package/script/package.json +0 -3
- package/script/src/ast/node.d.ts.map +0 -1
- package/script/src/ast/node.js +0 -33
- package/script/src/codegen/config.d.ts +0 -36
- package/script/src/codegen/config.d.ts.map +0 -1
- package/script/src/codegen/config.js +0 -12
- package/script/src/codegen/endpoints-generator.d.ts.map +0 -1
- package/script/src/codegen/endpoints-generator.js +0 -35
- package/script/src/codegen/generator.d.ts.map +0 -1
- package/script/src/codegen/generator.js +0 -134
- package/script/src/codegen/internal-utils.d.ts +0 -2
- package/script/src/codegen/internal-utils.d.ts.map +0 -1
- package/script/src/codegen/internal-utils.js +0 -9
- package/script/src/codegen/schemas-generator.d.ts.map +0 -1
- package/script/src/codegen/schemas-generator.js +0 -49
- package/script/src/codegen/services-generator.d.ts +0 -18
- package/script/src/codegen/services-generator.d.ts.map +0 -1
- package/script/src/codegen/services-generator.js +0 -35
- package/script/src/codegen/types.d.ts.map +0 -1
- package/script/src/codegen/types.js +0 -2
- package/script/src/collect/collector.d.ts +0 -5
- package/script/src/collect/collector.d.ts.map +0 -1
- package/script/src/collect/collector.js +0 -122
- package/script/src/collect/helpers.d.ts +0 -5
- package/script/src/collect/helpers.d.ts.map +0 -1
- package/script/src/collect/helpers.js +0 -37
- package/script/src/collect/types.d.ts.map +0 -1
- package/script/src/collect/types.js +0 -2
- package/script/src/internal-utils.d.ts +0 -2
- package/script/src/internal-utils.d.ts.map +0 -1
- package/script/src/internal-utils.js +0 -6
- package/script/src/parse/deref-proxy.d.ts +0 -4
- package/script/src/parse/deref-proxy.d.ts.map +0 -1
- package/script/src/parse/deref-proxy.js +0 -71
- package/script/src/parse/openapi-types.d.ts +0 -902
- package/script/src/parse/openapi-types.d.ts.map +0 -1
- package/script/src/parse/openapi-types.js +0 -2
- package/script/src/parse/parser.d.ts +0 -18
- package/script/src/parse/parser.d.ts.map +0 -1
- package/script/src/parse/parser.js +0 -183
- package/script/src/parse/types.d.ts.map +0 -1
- package/script/src/parse/types.js +0 -5
- package/script/src/transform/api-types.d.ts.map +0 -1
- package/script/src/transform/api-types.js +0 -2
- package/script/src/transform/helpers.d.ts +0 -58
- package/script/src/transform/helpers.d.ts.map +0 -1
- package/script/src/transform/helpers.js +0 -211
- package/script/src/transform/transform-document.d.ts +0 -5
- package/script/src/transform/transform-document.d.ts.map +0 -1
- package/script/src/transform/transform-document.js +0 -34
- package/script/src/transform/transform-endpoint.d.ts +0 -5
- package/script/src/transform/transform-endpoint.d.ts.map +0 -1
- package/script/src/transform/transform-endpoint.js +0 -273
- package/script/src/transform/transform-schema.d.ts +0 -6
- package/script/src/transform/transform-schema.d.ts.map +0 -1
- package/script/src/transform/transform-schema.js +0 -196
- package/script/src/transform/transformer.d.ts +0 -5
- package/script/src/transform/transformer.d.ts.map +0 -1
- package/script/src/transform/transformer.js +0 -45
- package/script/src/transform/types.d.ts +0 -36
- package/script/src/transform/types.d.ts.map +0 -1
- package/script/src/transform/types.js +0 -6
- package/script/src/utils/action-provider.d.ts.map +0 -1
- package/script/src/utils/action-provider.js +0 -33
- package/script/src/utils/api-data.utils.d.ts +0 -3
- package/script/src/utils/api-data.utils.d.ts.map +0 -1
- package/script/src/utils/api-data.utils.js +0 -42
- package/script/src/utils/array.utils.d.ts +0 -2
- package/script/src/utils/array.utils.d.ts.map +0 -1
- package/script/src/utils/array.utils.js +0 -10
- package/script/src/utils/asset-manager.d.ts.map +0 -1
- package/script/src/utils/asset-manager.js +0 -55
- package/script/src/utils/class.utils.d.ts +0 -8
- package/script/src/utils/class.utils.d.ts.map +0 -1
- package/script/src/utils/class.utils.js +0 -33
- package/script/src/utils/common.utils.d.ts.map +0 -1
- package/script/src/utils/common.utils.js +0 -84
- package/script/src/utils/condition.d.ts +0 -4
- package/script/src/utils/condition.d.ts.map +0 -1
- package/script/src/utils/condition.js +0 -7
- package/script/src/utils/endpoint.utils.d.ts +0 -3
- package/script/src/utils/endpoint.utils.d.ts.map +0 -1
- package/script/src/utils/endpoint.utils.js +0 -11
- package/script/src/utils/error.utils.d.ts +0 -2
- package/script/src/utils/error.utils.d.ts.map +0 -1
- package/script/src/utils/error.utils.js +0 -6
- package/script/src/utils/factory.d.ts +0 -21
- package/script/src/utils/factory.d.ts.map +0 -1
- package/script/src/utils/factory.js +0 -33
- package/script/src/utils/file-system.utils.d.ts +0 -11
- package/script/src/utils/file-system.utils.d.ts.map +0 -1
- package/script/src/utils/file-system.utils.js +0 -79
- package/script/src/utils/generator.utils.d.ts +0 -2
- package/script/src/utils/generator.utils.d.ts.map +0 -1
- package/script/src/utils/generator.utils.js +0 -9
- package/script/src/utils/object.utils.d.ts +0 -3
- package/script/src/utils/object.utils.d.ts.map +0 -1
- package/script/src/utils/object.utils.js +0 -40
- package/script/src/utils/schema.utils.d.ts +0 -12
- package/script/src/utils/schema.utils.d.ts.map +0 -1
- package/script/src/utils/schema.utils.js +0 -206
- package/script/src/utils/source-builder.d.ts +0 -236
- package/script/src/utils/source-builder.d.ts.map +0 -1
- package/script/src/utils/source-builder.js +0 -458
- package/script/src/utils/string-builder/options.d.ts.map +0 -1
- package/script/src/utils/string-builder/options.js +0 -10
- package/script/src/utils/string-builder/string-builder.d.ts.map +0 -1
- package/script/src/utils/string-builder/string-builder.js +0 -153
- package/script/src/utils/string-builder/utils.d.ts +0 -22
- package/script/src/utils/string-builder/utils.d.ts.map +0 -1
- package/script/src/utils/string-builder/utils.js +0 -37
- package/script/src/utils/string.utils.d.ts.map +0 -1
- package/script/src/utils/string.utils.js +0 -382
- package/script/src/utils/string.utils.types.d.ts +0 -150
- package/script/src/utils/string.utils.types.d.ts.map +0 -1
- package/script/src/utils/string.utils.types.js +0 -2
- package/script/src/utils/type.utils.d.ts +0 -57
- package/script/src/utils/type.utils.d.ts.map +0 -1
- package/script/src/utils/type.utils.js +0 -10
- package/script/src/utils/yaml-info.d.ts.map +0 -1
- package/script/src/utils/yaml-info.js +0 -38
- package/src/_dnt.shims.ts +0 -69
- package/src/mod.ts +0 -35
- package/src/src/ast/node.ts +0 -46
- package/src/src/codegen/config.ts +0 -50
- package/src/src/codegen/endpoints-generator.ts +0 -72
- package/src/src/codegen/generator.ts +0 -192
- package/src/src/codegen/internal-utils.ts +0 -6
- package/src/src/codegen/schemas-generator.ts +0 -87
- package/src/src/codegen/services-generator.ts +0 -77
- package/src/src/codegen/types.ts +0 -37
- package/src/src/collect/collector.ts +0 -142
- package/src/src/collect/helpers.ts +0 -36
- package/src/src/collect/types.ts +0 -21
- package/src/src/internal-utils.ts +0 -5
- package/src/src/parse/deref-proxy.ts +0 -70
- package/src/src/parse/openapi-types.ts +0 -953
- package/src/src/parse/parser.ts +0 -206
- package/src/src/parse/types.ts +0 -28
- package/src/src/transform/api-types.ts +0 -259
- package/src/src/transform/helpers.ts +0 -251
- package/src/src/transform/transform-document.ts +0 -35
- package/src/src/transform/transform-endpoint.ts +0 -332
- package/src/src/transform/transform-schema.ts +0 -232
- package/src/src/transform/transformer.ts +0 -53
- package/src/src/transform/types.ts +0 -52
- package/src/src/utils/action-provider.ts +0 -58
- package/src/src/utils/api-data.utils.ts +0 -48
- package/src/src/utils/array.utils.ts +0 -7
- package/src/src/utils/asset-manager.ts +0 -51
- package/src/src/utils/class.utils.ts +0 -40
- package/src/src/utils/common.utils.ts +0 -86
- package/src/src/utils/condition.ts +0 -7
- package/src/src/utils/endpoint.utils.ts +0 -10
- package/src/src/utils/error.utils.ts +0 -3
- package/src/src/utils/factory.ts +0 -42
- package/src/src/utils/file-system.utils.ts +0 -97
- package/src/src/utils/generator.utils.ts +0 -6
- package/src/src/utils/object.utils.ts +0 -32
- package/src/src/utils/schema.utils.ts +0 -240
- package/src/src/utils/source-builder.ts +0 -597
- package/src/src/utils/string-builder/options.ts +0 -19
- package/src/src/utils/string-builder/string-builder.ts +0 -165
- package/src/src/utils/string-builder/utils.ts +0 -69
- package/src/src/utils/string.utils.ts +0 -394
- package/src/src/utils/string.utils.types.ts +0 -179
- package/src/src/utils/type.utils.ts +0 -93
- package/src/src/utils/yaml-info.ts +0 -48
- /package/{esm → dist}/mod.js +0 -0
- /package/{esm → dist}/src/codegen/config.js +0 -0
- /package/{esm → dist}/src/codegen/types.js +0 -0
- /package/{esm → dist}/src/collect/helpers.js +0 -0
- /package/{esm → dist}/src/collect/types.js +0 -0
- /package/{esm → dist}/src/internal-utils.js +0 -0
- /package/{esm → dist}/src/parse/openapi-types.js +0 -0
- /package/{esm → dist}/src/parse/types.js +0 -0
- /package/{esm → dist}/src/transform/api-types.js +0 -0
- /package/{esm → dist}/src/transform/transformer.js +0 -0
- /package/{esm → dist}/src/transform/types.js +0 -0
- /package/{esm → dist}/src/utils/api-data.utils.js +0 -0
- /package/{esm → dist}/src/utils/array.utils.js +0 -0
- /package/{esm → dist}/src/utils/common.utils.js +0 -0
- /package/{esm → dist}/src/utils/condition.js +0 -0
- /package/{esm → dist}/src/utils/endpoint.utils.js +0 -0
- /package/{esm → dist}/src/utils/error.utils.js +0 -0
- /package/{esm → dist}/src/utils/file-system.utils.js +0 -0
- /package/{esm → dist}/src/utils/generator.utils.js +0 -0
- /package/{esm → dist}/src/utils/string-builder/options.js +0 -0
- /package/{esm → dist}/src/utils/string.utils.types.js +0 -0
- /package/{esm → dist}/src/utils/type.utils.js +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OpenApiDocument } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { Deref } from '../parse/types.ts';
|
|
3
|
+
import type { OpenApiTransformerContext } from './types.ts';
|
|
4
|
+
export declare function transformDocument(context: OpenApiTransformerContext, document: Deref<OpenApiDocument>): void;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { getOpenApiObjectIdentifier } from './helpers.js';
|
|
2
2
|
export function transformDocument(context, document) {
|
|
3
|
-
|
|
4
|
-
for (const tag of (_a = document.tags) !== null && _a !== void 0 ? _a : []) {
|
|
3
|
+
for (const tag of document.tags ?? []) {
|
|
5
4
|
transformTag(context, tag);
|
|
6
5
|
}
|
|
7
6
|
}
|
|
8
7
|
function transformTag(context, tag, isReference = false) {
|
|
9
|
-
var _a;
|
|
10
8
|
const openApiObjectId = getOpenApiObjectIdentifier(tag);
|
|
11
9
|
const existing = context.transformed.services.get(openApiObjectId);
|
|
12
10
|
if (existing)
|
|
@@ -20,7 +18,7 @@ function transformTag(context, tag, isReference = false) {
|
|
|
20
18
|
},
|
|
21
19
|
$ref: ref,
|
|
22
20
|
id,
|
|
23
|
-
name:
|
|
21
|
+
name: tag.name ?? id,
|
|
24
22
|
description: tag.description,
|
|
25
23
|
endpoints: [],
|
|
26
24
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { OpenApiCollectorEndpointInfo } from '../collect/types.
|
|
2
|
-
import type { ApiEndpoint } from './api-types.
|
|
3
|
-
import type { OpenApiTransformerContext } from './types.
|
|
1
|
+
import type { OpenApiCollectorEndpointInfo } from '../collect/types.ts';
|
|
2
|
+
import type { ApiEndpoint } from './api-types.ts';
|
|
3
|
+
import type { OpenApiTransformerContext } from './types.ts';
|
|
4
4
|
export declare function transformEndpoint(context: OpenApiTransformerContext, endpointInfo: OpenApiCollectorEndpointInfo): ApiEndpoint;
|
|
5
|
-
//# sourceMappingURL=transform-endpoint.d.ts.map
|
|
@@ -2,7 +2,6 @@ import { isOpenApiObjectProperty } from '../internal-utils.js';
|
|
|
2
2
|
import { determineEndpointName, getCustomFields, getOpenApiObjectIdentifier } from './helpers.js';
|
|
3
3
|
import { transformSchema } from './transform-schema.js';
|
|
4
4
|
export function transformEndpoint(context, endpointInfo) {
|
|
5
|
-
var _a, _b, _c, _d;
|
|
6
5
|
const apiPath = transformApiPath(context, endpointInfo.path, endpointInfo.pathItem);
|
|
7
6
|
const endpoint = {
|
|
8
7
|
$src: {
|
|
@@ -17,13 +16,13 @@ export function transformEndpoint(context, endpointInfo) {
|
|
|
17
16
|
method: endpointInfo.method,
|
|
18
17
|
summary: endpointInfo.operation.summary,
|
|
19
18
|
description: endpointInfo.operation.description,
|
|
20
|
-
parameters: combineParameters(apiPath.parameters,
|
|
21
|
-
deprecated:
|
|
19
|
+
parameters: combineParameters(apiPath.parameters, endpointInfo.operation.parameters?.map((p) => transformParameter(context, p)) ?? []),
|
|
20
|
+
deprecated: endpointInfo.operation.deprecated ?? false,
|
|
22
21
|
requestBody: endpointInfo.operation.requestBody
|
|
23
22
|
? transformRequestBody(context, endpointInfo.operation.requestBody)
|
|
24
23
|
: undefined,
|
|
25
24
|
responses: transformResponses(context, endpointInfo.operation.responses),
|
|
26
|
-
tags:
|
|
25
|
+
tags: endpointInfo.operation.tags ?? [],
|
|
27
26
|
custom: getCustomFields(endpointInfo.operation),
|
|
28
27
|
};
|
|
29
28
|
const tags = endpoint.tags.length === 0 ? [''] : endpoint.tags;
|
|
@@ -47,7 +46,6 @@ export function transformEndpoint(context, endpointInfo) {
|
|
|
47
46
|
return endpoint;
|
|
48
47
|
}
|
|
49
48
|
function transformApiPath(context, path, pathItem, isReference = false) {
|
|
50
|
-
var _a, _b;
|
|
51
49
|
const existingPath = context.paths.get(path);
|
|
52
50
|
if (existingPath)
|
|
53
51
|
return existingPath;
|
|
@@ -66,7 +64,7 @@ function transformApiPath(context, path, pathItem, isReference = false) {
|
|
|
66
64
|
summary: pathItem.summary,
|
|
67
65
|
description: pathItem.description,
|
|
68
66
|
path: path,
|
|
69
|
-
parameters:
|
|
67
|
+
parameters: pathItem.parameters?.map((p) => transformParameter(context, p)) ?? [],
|
|
70
68
|
// HTTP methods are added later (see transformEndpoint)
|
|
71
69
|
get: undefined,
|
|
72
70
|
put: undefined,
|
|
@@ -83,7 +81,6 @@ function transformApiPath(context, path, pathItem, isReference = false) {
|
|
|
83
81
|
return apiPath;
|
|
84
82
|
}
|
|
85
83
|
function transformParameter(context, parameter) {
|
|
86
|
-
var _a, _b, _c;
|
|
87
84
|
const openApiObjectId = getOpenApiObjectIdentifier(parameter);
|
|
88
85
|
const existing = context.transformed.parameters.get(openApiObjectId);
|
|
89
86
|
if (existing)
|
|
@@ -97,11 +94,11 @@ function transformParameter(context, parameter) {
|
|
|
97
94
|
},
|
|
98
95
|
$ref: ref,
|
|
99
96
|
id: id,
|
|
100
|
-
name:
|
|
97
|
+
name: parameter.name ?? id,
|
|
101
98
|
target: parameter.in,
|
|
102
99
|
description: parameter.description,
|
|
103
|
-
required:
|
|
104
|
-
deprecated:
|
|
100
|
+
required: parameter.required ?? false,
|
|
101
|
+
deprecated: parameter.deprecated ?? false,
|
|
105
102
|
allowEmptyValue: parameter.allowEmptyValue,
|
|
106
103
|
style: parameter.style,
|
|
107
104
|
explode: parameter.explode,
|
|
@@ -112,7 +109,6 @@ function transformParameter(context, parameter) {
|
|
|
112
109
|
return p;
|
|
113
110
|
}
|
|
114
111
|
function transformRequestBody(context, requestBody) {
|
|
115
|
-
var _a;
|
|
116
112
|
const openApiObjectId = getOpenApiObjectIdentifier(requestBody);
|
|
117
113
|
const existing = context.transformed.requestBodies.get(openApiObjectId);
|
|
118
114
|
if (existing)
|
|
@@ -126,7 +122,7 @@ function transformRequestBody(context, requestBody) {
|
|
|
126
122
|
$ref: ref,
|
|
127
123
|
id: context.idGenerator.generateId('requestBody'),
|
|
128
124
|
description: requestBody.description,
|
|
129
|
-
required:
|
|
125
|
+
required: requestBody.required ?? false,
|
|
130
126
|
content: transformContent(context, requestBody.content),
|
|
131
127
|
};
|
|
132
128
|
context.transformed.requestBodies.set(openApiObjectId, rb);
|
|
@@ -223,7 +219,6 @@ function transformHeaders(context, headers) {
|
|
|
223
219
|
return result;
|
|
224
220
|
}
|
|
225
221
|
function transformHeader(context, header, name) {
|
|
226
|
-
var _a, _b;
|
|
227
222
|
const openApiObjectId = getOpenApiObjectIdentifier(header);
|
|
228
223
|
const existing = context.transformed.headers.get(openApiObjectId);
|
|
229
224
|
if (existing)
|
|
@@ -233,7 +228,6 @@ function transformHeader(context, header, name) {
|
|
|
233
228
|
const id = context.idGenerator.generateId('header');
|
|
234
229
|
if (isSchema(header)) {
|
|
235
230
|
h = {
|
|
236
|
-
// deno-lint-ignore no-explicit-any
|
|
237
231
|
$src: Object.assign({}, header.$src, { component: header }),
|
|
238
232
|
$ref: ref,
|
|
239
233
|
id,
|
|
@@ -250,14 +244,13 @@ function transformHeader(context, header, name) {
|
|
|
250
244
|
}
|
|
251
245
|
else {
|
|
252
246
|
h = {
|
|
253
|
-
// deno-lint-ignore no-explicit-any
|
|
254
247
|
$src: Object.assign({}, header.$src, { component: header }),
|
|
255
248
|
$ref: ref,
|
|
256
249
|
id,
|
|
257
250
|
name,
|
|
258
251
|
description: header.description,
|
|
259
|
-
required:
|
|
260
|
-
deprecated:
|
|
252
|
+
required: header.required ?? false,
|
|
253
|
+
deprecated: header.deprecated ?? false,
|
|
261
254
|
allowEmptyValue: header.allowEmptyValue,
|
|
262
255
|
style: header.style,
|
|
263
256
|
explode: header.explode,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OpenApiSchema } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { Deref } from '../parse/types.ts';
|
|
3
|
+
import type { ApiSchema } from './api-types.ts';
|
|
4
|
+
import type { OpenApiTransformerContext } from './types.ts';
|
|
5
|
+
export declare function transformSchema<T extends Deref<OpenApiSchema>>(ctx: OpenApiTransformerContext, schema: T): ApiSchema;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createOverwriteProxy } from '../utils/object.utils.js';
|
|
2
2
|
import { asTypeArray, determineSchemaAccessibility, determineSchemaKind, determineSchemaName, getCustomFields, getOpenApiObjectIdentifier, hasNullType, transformAdditionalProperties, transformSchemaProperties, withoutNullType, } from './helpers.js';
|
|
3
3
|
export function transformSchema(ctx, schema) {
|
|
4
|
-
var _a, _b, _c;
|
|
5
4
|
if (!schema) {
|
|
6
5
|
throw new Error('Schema is required.');
|
|
7
6
|
}
|
|
8
7
|
const schemaSource = `${schema.$src.file}:${schema.$src.path}`;
|
|
9
|
-
const existingSchema =
|
|
8
|
+
const existingSchema = ctx.schemas.get(schemaSource) ?? ctx.incompleteSchemas.get(schemaSource);
|
|
10
9
|
if (existingSchema)
|
|
11
10
|
return existingSchema;
|
|
12
11
|
const openApiObjectId = getOpenApiObjectIdentifier(schema);
|
|
@@ -23,7 +22,7 @@ export function transformSchema(ctx, schema) {
|
|
|
23
22
|
if (remainingTypes.length === 0) {
|
|
24
23
|
// A type array that contains nothing but `null` constrains nullability only. If the schema also has a
|
|
25
24
|
// `$ref`, the actual type is the referenced one; otherwise the schema really is just the null type.
|
|
26
|
-
remainingTypes = withoutNullType(asTypeArray(
|
|
25
|
+
remainingTypes = withoutNullType(asTypeArray(schema.$ref?.type));
|
|
27
26
|
}
|
|
28
27
|
if (remainingTypes.length > 1) {
|
|
29
28
|
// Still a genuine multi-type schema; only the `null` member is absorbed into `nullable`.
|
|
@@ -52,7 +51,7 @@ export function transformSchema(ctx, schema) {
|
|
|
52
51
|
name: nameInfo.name,
|
|
53
52
|
isNameGenerated: nameInfo.isGenerated,
|
|
54
53
|
description: schema.description,
|
|
55
|
-
deprecated:
|
|
54
|
+
deprecated: schema.deprecated ?? false,
|
|
56
55
|
accessibility: determineSchemaAccessibility(schema),
|
|
57
56
|
kind,
|
|
58
57
|
enum: schema.enum,
|
|
@@ -65,9 +64,7 @@ export function transformSchema(ctx, schema) {
|
|
|
65
64
|
const: schema.const,
|
|
66
65
|
discriminator: schema.discriminator
|
|
67
66
|
? {
|
|
68
|
-
propertyName: typeof schema.discriminator === 'string'
|
|
69
|
-
? schema.discriminator
|
|
70
|
-
: schema.discriminator.propertyName,
|
|
67
|
+
propertyName: typeof schema.discriminator === 'string' ? schema.discriminator : schema.discriminator.propertyName,
|
|
71
68
|
mapping: {},
|
|
72
69
|
}
|
|
73
70
|
: undefined,
|
|
@@ -86,13 +83,12 @@ export function transformSchema(ctx, schema) {
|
|
|
86
83
|
return completeSchema;
|
|
87
84
|
}
|
|
88
85
|
function allExtensionsTransformer(schema, context) {
|
|
89
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
90
86
|
// A schema with `prefixItems` is a tuple. Tuples are not modelled, but the `items` schema of a tuple only
|
|
91
87
|
// describes the elements *after* the prefix, so it must not be reported as the element schema of the array:
|
|
92
88
|
// that would actively mistype the array instead of leaving its elements unspecified.
|
|
93
|
-
const isTuple = (
|
|
89
|
+
const isTuple = (schema.prefixItems?.length ?? 0) > 0;
|
|
94
90
|
return {
|
|
95
|
-
oneOf:
|
|
91
|
+
oneOf: schema.oneOf?.map((s) => transformSchema(context, s)) ?? [],
|
|
96
92
|
format: schema.format,
|
|
97
93
|
pattern: schema.pattern,
|
|
98
94
|
minLength: schema.minLength,
|
|
@@ -101,8 +97,8 @@ function allExtensionsTransformer(schema, context) {
|
|
|
101
97
|
maximum: schema.maximum,
|
|
102
98
|
properties: transformSchemaProperties(context, schema, transformSchema),
|
|
103
99
|
additionalProperties: transformAdditionalProperties(context, schema, transformSchema),
|
|
104
|
-
allOf:
|
|
105
|
-
anyOf:
|
|
100
|
+
allOf: schema.allOf?.map((s) => transformSchema(context, s)) ?? [],
|
|
101
|
+
anyOf: schema.anyOf?.map((s) => transformSchema(context, s)) ?? [],
|
|
106
102
|
items: !isTuple && schema.items ? transformSchema(context, schema.items) : undefined,
|
|
107
103
|
minItems: schema.minItems,
|
|
108
104
|
maxItems: schema.maxItems,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OpenApiCollectorData } from '../collect/types.ts';
|
|
2
|
+
import type { ApiData } from './api-types.ts';
|
|
3
|
+
import { type OpenApiTransformerOptions } from './types.ts';
|
|
4
|
+
export declare function transformOpenApi(data: OpenApiCollectorData, options?: Partial<OpenApiTransformerOptions>): ApiData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { OpenApiCollectorData } from '../collect/types.
|
|
2
|
-
import type { ArrayItem } from '../utils/type.utils.
|
|
3
|
-
import type { ApiContent, ApiData, ApiHeader, ApiParameter, ApiPath, ApiRequestBody, ApiResponse, ApiSchema, ApiSchemaExtensions, ApiSchemaKind, ApiService } from './api-types.
|
|
4
|
-
import type { IdGenerator } from './helpers.
|
|
1
|
+
import type { OpenApiCollectorData } from '../collect/types.ts';
|
|
2
|
+
import type { ArrayItem } from '../utils/type.utils.ts';
|
|
3
|
+
import type { ApiContent, ApiData, ApiHeader, ApiParameter, ApiPath, ApiRequestBody, ApiResponse, ApiSchema, ApiSchemaExtensions, ApiSchemaKind, ApiService } from './api-types.ts';
|
|
4
|
+
import type { IdGenerator } from './helpers.ts';
|
|
5
5
|
export type OpenApiTransformerOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* Determines how schemas without a `type` property should be treated.
|
|
@@ -33,4 +33,3 @@ export type OpenApiTransformerContext = {
|
|
|
33
33
|
} & {
|
|
34
34
|
[K in Exclude<keyof ApiData, 'documents'>]: Map<string, ArrayItem<ApiData[K]>>;
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmptyConstructor, FunctionNames } from './type.utils.
|
|
1
|
+
import type { EmptyConstructor, FunctionNames } from './type.utils.ts';
|
|
2
2
|
type MatchingFunctionNames<T, TAction> = {
|
|
3
3
|
[K in keyof T]: T[K] extends TAction ? K : never;
|
|
4
4
|
}[keyof T];
|
|
@@ -19,11 +19,10 @@ type ValueActionRunner<T, TAction> = {
|
|
|
19
19
|
type ActionRunner<TAction> = CtorActionRunner<any, TAction> | FnActionRunner<TAction> | ValueActionRunner<any, TAction>;
|
|
20
20
|
export declare class ActionProvider<TAction extends (...args: any[]) => any> {
|
|
21
21
|
private readonly _runner;
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(runner: ActionRunner<TAction>);
|
|
23
23
|
run(...args: Parameters<TAction>): ReturnType<TAction>;
|
|
24
24
|
static fromType<T, TName extends FunctionNames<T>>(type: EmptyConstructor<T>, functionName: TName): ActionProvider<T[TName] extends (...args: any[]) => any ? T[TName] : never>;
|
|
25
25
|
static fromFn<TAction extends (...args: any[]) => any>(fn: TAction): ActionProvider<TAction>;
|
|
26
26
|
static fromValue<T, TName extends FunctionNames<T>>(value: T, functionName: TName): ActionProvider<T[TName] extends (...args: any[]) => any ? T[TName] : never>;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
29
|
-
//# sourceMappingURL=action-provider.d.ts.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
export class ActionProvider {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: _runner
|
|
8
|
-
});
|
|
2
|
+
_runner;
|
|
3
|
+
constructor(runner) {
|
|
4
|
+
this._runner = runner;
|
|
9
5
|
}
|
|
10
6
|
run(...args) {
|
|
11
7
|
switch (this._runner.kind) {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { ApiComponent, ApiData } from '../transform/api-types.
|
|
1
|
+
import type { ApiComponent, ApiData } from '../transform/api-types.ts';
|
|
2
2
|
export declare function getSourceDisplayName<T>(data: ApiData, component: ApiComponent<T>): string;
|
|
3
|
-
//# sourceMappingURL=api-data.utils.d.ts.map
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import * as dntShim from "../../_dnt.shims.js";
|
|
2
1
|
import { basename, resolve } from 'node:path';
|
|
3
2
|
import { fileURLToPath, URL } from 'node:url';
|
|
4
3
|
import fs from 'fs-extra';
|
|
5
4
|
export class AssetManager {
|
|
5
|
+
_assetsBaseUrl;
|
|
6
6
|
constructor(assetsBaseUrl) {
|
|
7
|
-
Object.defineProperty(this, "_assetsBaseUrl", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: void 0
|
|
12
|
-
});
|
|
13
7
|
this._assetsBaseUrl = assetsBaseUrl;
|
|
14
8
|
}
|
|
15
9
|
async getAssetFileContent(relativePath) {
|
|
@@ -41,7 +35,7 @@ export class AssetManager {
|
|
|
41
35
|
}
|
|
42
36
|
async fetchAssetFile(relativePath) {
|
|
43
37
|
const url = new URL(relativePath, this._assetsBaseUrl);
|
|
44
|
-
const response = await
|
|
38
|
+
const response = await fetch(url);
|
|
45
39
|
if (!response.ok) {
|
|
46
40
|
throw new Error(`Failed to fetch asset file "${relativePath}" from "${url.href}": ${response.statusText} (${response.status})`);
|
|
47
41
|
}
|
|
@@ -5,4 +5,3 @@ export declare function classifyArray<TItem, TClassification extends Record<stri
|
|
|
5
5
|
};
|
|
6
6
|
export declare function isInstanceOf<T>(item: unknown, type: abstract new (...args: any[]) => T): item is T;
|
|
7
7
|
export declare function getIsInstanceOf<T>(type: abstract new (...args: any[]) => T): (item: unknown) => item is T;
|
|
8
|
-
//# sourceMappingURL=class.utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SingleOrMultiple } from './type.utils.
|
|
1
|
+
import type { SingleOrMultiple } from './type.utils.ts';
|
|
2
2
|
export declare function isNullish(value: unknown): value is null | undefined;
|
|
3
3
|
export declare function notNullish<T>(value: T): value is NonNullable<T>;
|
|
4
4
|
export declare function concatSingleOrMultiple<T>(...values: SingleOrMultiple<T>[]): SingleOrMultiple<T>;
|
|
@@ -13,4 +13,3 @@ export declare function runEach<T extends Iterable<unknown>>(values: T, callback
|
|
|
13
13
|
export declare function transformEach<T, U>(values: Iterable<T>, callback: (value: T) => U): U[];
|
|
14
14
|
export declare function asVoid(_: unknown): void;
|
|
15
15
|
export {};
|
|
16
|
-
//# sourceMappingURL=common.utils.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export type Condition<T = never> = boolean | ([T] extends [never] ? () => boolean : (ctx: T) => boolean);
|
|
2
2
|
export declare function evalCondition(condition: Condition<never>): boolean;
|
|
3
3
|
export declare function evalCondition<T>(condition: Condition<T>, ctx: T): boolean;
|
|
4
|
-
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Constructor } from './type.utils.
|
|
1
|
+
import type { Constructor } from './type.utils.ts';
|
|
2
2
|
type FactoryProvider<T, TArgs extends unknown[]> = {
|
|
3
3
|
kind: 'ctor';
|
|
4
4
|
factory: Constructor<T, TArgs>;
|
|
@@ -11,11 +11,10 @@ type FactoryProvider<T, TArgs extends unknown[]> = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare class Factory<T, TArgs extends unknown[]> {
|
|
13
13
|
private readonly _provider;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(provider: FactoryProvider<T, TArgs>);
|
|
15
15
|
create(...args: TArgs): T;
|
|
16
16
|
static fromType<T, TArgs extends unknown[]>(type: Constructor<T, TArgs>): Factory<T, TArgs>;
|
|
17
17
|
static fromFn<T, TArgs extends unknown[]>(fn: (...args: TArgs) => T): Factory<T, TArgs>;
|
|
18
18
|
static fromValue<T>(value: T): Factory<T, []>;
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
21
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
export class Factory {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: _provider
|
|
8
|
-
});
|
|
2
|
+
_provider;
|
|
3
|
+
constructor(provider) {
|
|
4
|
+
this._provider = provider;
|
|
9
5
|
}
|
|
10
6
|
create(...args) {
|
|
11
7
|
switch (this._provider.kind) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OpenApiGeneratorConfig } from '../codegen/config.
|
|
2
|
-
import type { Nullable } from './type.utils.
|
|
1
|
+
import type { OpenApiGeneratorConfig } from '../codegen/config.ts';
|
|
2
|
+
import type { Nullable } from './type.utils.ts';
|
|
3
3
|
export type DirectoryScanOptions = {
|
|
4
4
|
recursive: boolean;
|
|
5
5
|
maxDepth: Nullable<number>;
|
|
@@ -8,4 +8,3 @@ export type DirectoryScanOptions = {
|
|
|
8
8
|
export declare const defaultDirectoryScanOptions: DirectoryScanOptions;
|
|
9
9
|
export declare function getFiles(dir: string, options?: Partial<DirectoryScanOptions>): Promise<string[]>;
|
|
10
10
|
export declare function writeGeneratedFile(config: OpenApiGeneratorConfig, filePath: string, content: string): void;
|
|
11
|
-
//# sourceMappingURL=file-system.utils.d.ts.map
|
|
@@ -11,23 +11,14 @@ export function getDeepProperty(obj, path) {
|
|
|
11
11
|
if (!current || typeof current !== 'object') {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
|
-
// deno-lint-ignore no-explicit-any
|
|
15
14
|
current = current[key];
|
|
16
15
|
}
|
|
17
16
|
return current;
|
|
18
17
|
}
|
|
19
18
|
class OverwriteProxyHandler {
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(this, "_overwrittenValues", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: {}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
19
|
+
_overwrittenValues = {};
|
|
28
20
|
get(target, prop) {
|
|
29
|
-
|
|
30
|
-
return (_a = this._overwrittenValues[prop]) !== null && _a !== void 0 ? _a : target[prop];
|
|
21
|
+
return this._overwrittenValues[prop] ?? target[prop];
|
|
31
22
|
}
|
|
32
23
|
set(_target, prop, value) {
|
|
33
24
|
this._overwrittenValues[prop] = value;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ApiSchema, ApiSchemaBase, ApiSchemaComponent, ApiSchemaExtensions, ApiSchemaProperty } from '../transform/api-types.ts';
|
|
2
|
+
export type TestSchema = Partial<Omit<ApiSchemaBase, 'required'>> & Partial<ApiSchemaComponent> & {
|
|
3
|
+
required?: string[];
|
|
4
|
+
};
|
|
5
|
+
export type TestOneofSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'oneOf'>, 'kind'>>;
|
|
6
|
+
export type TestMultiTypeSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'multi-type'>, 'kind' | 'properties'>> & {
|
|
7
|
+
properties?: ApiSchemaProperty[];
|
|
8
|
+
};
|
|
9
|
+
export type TestStringSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'string'>, 'kind' | 'type'>>;
|
|
10
|
+
export type TestBooleanSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'boolean'>, 'kind' | 'type'>>;
|
|
11
|
+
export type TestNullSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'null'>, 'kind' | 'type'>>;
|
|
12
|
+
export type TestNumberSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'number'>, 'kind' | 'type'>>;
|
|
13
|
+
export type TestIntegerSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'integer'>, 'kind' | 'type'>>;
|
|
14
|
+
export type TestArraySchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'array'>, 'kind' | 'type'>>;
|
|
15
|
+
export type TestObjectSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'object'>, 'kind' | 'type' | 'properties'>> & {
|
|
16
|
+
properties?: ApiSchemaProperty[];
|
|
17
|
+
};
|
|
18
|
+
export type TestCombinedSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'combined'>, 'kind'>>;
|
|
19
|
+
export type TestUnknownSchema = TestSchema & Partial<Omit<ApiSchemaExtensions<'unknown'>, 'kind'>>;
|
|
20
|
+
export declare function createOneOfSchema(schema?: TestOneofSchema): ApiSchema<'oneOf'>;
|
|
21
|
+
export declare function createMultiTypeSchema(schema?: TestMultiTypeSchema): ApiSchema<'multi-type'>;
|
|
22
|
+
export declare function createStringSchema(schema?: TestStringSchema): ApiSchema<'string'>;
|
|
23
|
+
export declare function createBooleanSchema(schema?: TestBooleanSchema): ApiSchema<'boolean'>;
|
|
24
|
+
export declare function createNullSchema(schema?: TestNullSchema): ApiSchema<'null'>;
|
|
25
|
+
export declare function createNumberSchema(schema?: TestNumberSchema): ApiSchema<'number'>;
|
|
26
|
+
export declare function createIntegerSchema(schema?: TestIntegerSchema): ApiSchema<'integer'>;
|
|
27
|
+
export declare function createArraySchema(schema?: TestArraySchema): ApiSchema<'array'>;
|
|
28
|
+
export declare function createObjectSchema(schema?: TestObjectSchema): ApiSchema<'object'>;
|
|
29
|
+
export declare function createCombinedSchema(schema?: TestCombinedSchema): ApiSchema<'combined'>;
|
|
30
|
+
export declare function createUnknownSchema(schema?: TestUnknownSchema): ApiSchema<'unknown'>;
|
|
31
|
+
export declare function createOneOfProperty(name: string, schema?: TestOneofSchema): ApiSchemaProperty;
|
|
32
|
+
export declare function createMultiTypeProperty(name: string, schema?: TestMultiTypeSchema): ApiSchemaProperty;
|
|
33
|
+
export declare function createStringProperty(name: string, schema?: TestStringSchema): ApiSchemaProperty;
|
|
34
|
+
export declare function createBooleanProperty(name: string, schema?: TestBooleanSchema): ApiSchemaProperty;
|
|
35
|
+
export declare function createNullProperty(name: string, schema?: TestNullSchema): ApiSchemaProperty;
|
|
36
|
+
export declare function createNumberProperty(name: string, schema?: TestNumberSchema): ApiSchemaProperty;
|
|
37
|
+
export declare function createIntegerProperty(name: string, schema?: TestIntegerSchema): ApiSchemaProperty;
|
|
38
|
+
export declare function createArrayProperty(name: string, schema?: TestArraySchema): ApiSchemaProperty;
|
|
39
|
+
export declare function createObjectProperty(name: string, schema?: TestObjectSchema): ApiSchemaProperty;
|
|
40
|
+
export declare function createCombinedProperty(name: string, schema?: TestCombinedSchema): ApiSchemaProperty;
|
|
41
|
+
export declare function createUnknownProperty(name: string, schema?: TestUnknownSchema): ApiSchemaProperty;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
let nextId = 0;
|
|
2
|
+
function createSchemaBase(schema) {
|
|
3
|
+
const name = schema.name ?? `schema-${nextId++}`;
|
|
4
|
+
return {
|
|
5
|
+
...schema,
|
|
6
|
+
name,
|
|
7
|
+
$src: schema.$src,
|
|
8
|
+
id: schema.id ?? name,
|
|
9
|
+
isNameGenerated: schema.isNameGenerated ?? schema.id !== undefined,
|
|
10
|
+
deprecated: schema.deprecated ?? false,
|
|
11
|
+
accessibility: schema.accessibility ?? 'all',
|
|
12
|
+
required: new Set(schema.required ?? []),
|
|
13
|
+
custom: {},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function createOneOfSchema(schema = {}) {
|
|
17
|
+
return {
|
|
18
|
+
...createSchemaBase(schema),
|
|
19
|
+
kind: 'oneOf',
|
|
20
|
+
oneOf: schema.oneOf ?? [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function createMultiTypeSchema(schema = {}) {
|
|
24
|
+
return {
|
|
25
|
+
...createSchemaBase(schema),
|
|
26
|
+
kind: 'multi-type',
|
|
27
|
+
type: schema.type ?? [],
|
|
28
|
+
properties: new Map((schema.properties ?? []).map((p) => [p.name, p])),
|
|
29
|
+
allOf: schema.allOf ?? [],
|
|
30
|
+
anyOf: schema.anyOf ?? [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function createStringSchema(schema = {}) {
|
|
34
|
+
return {
|
|
35
|
+
...createSchemaBase(schema),
|
|
36
|
+
kind: 'string',
|
|
37
|
+
type: 'string',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function createBooleanSchema(schema = {}) {
|
|
41
|
+
return {
|
|
42
|
+
...createSchemaBase(schema),
|
|
43
|
+
kind: 'boolean',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function createNullSchema(schema = {}) {
|
|
48
|
+
return {
|
|
49
|
+
...createSchemaBase(schema),
|
|
50
|
+
kind: 'null',
|
|
51
|
+
type: 'null',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function createNumberSchema(schema = {}) {
|
|
55
|
+
return {
|
|
56
|
+
...createSchemaBase(schema),
|
|
57
|
+
kind: 'number',
|
|
58
|
+
type: 'number',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function createIntegerSchema(schema = {}) {
|
|
62
|
+
return {
|
|
63
|
+
...createSchemaBase(schema),
|
|
64
|
+
kind: 'integer',
|
|
65
|
+
type: 'integer',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function createArraySchema(schema = {}) {
|
|
69
|
+
return {
|
|
70
|
+
...createSchemaBase(schema),
|
|
71
|
+
kind: 'array',
|
|
72
|
+
type: 'array',
|
|
73
|
+
items: schema.items ?? undefined,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function createObjectSchema(schema = {}) {
|
|
77
|
+
return {
|
|
78
|
+
...createSchemaBase(schema),
|
|
79
|
+
kind: 'object',
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: new Map((schema.properties ?? []).map((p) => [p.name, p])),
|
|
82
|
+
allOf: schema.allOf ?? [],
|
|
83
|
+
anyOf: schema.anyOf ?? [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function createCombinedSchema(schema = {}) {
|
|
87
|
+
return {
|
|
88
|
+
...createSchemaBase(schema),
|
|
89
|
+
kind: 'combined',
|
|
90
|
+
allOf: schema.allOf ?? [],
|
|
91
|
+
anyOf: schema.anyOf ?? [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function createUnknownSchema(schema = {}) {
|
|
95
|
+
return {
|
|
96
|
+
...createSchemaBase(schema),
|
|
97
|
+
kind: 'unknown',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function createOneOfProperty(name, schema = {}) {
|
|
101
|
+
return { name, schema: createOneOfSchema(schema) };
|
|
102
|
+
}
|
|
103
|
+
export function createMultiTypeProperty(name, schema = {}) {
|
|
104
|
+
return { name, schema: createMultiTypeSchema(schema) };
|
|
105
|
+
}
|
|
106
|
+
export function createStringProperty(name, schema = {}) {
|
|
107
|
+
return { name, schema: createStringSchema(schema) };
|
|
108
|
+
}
|
|
109
|
+
export function createBooleanProperty(name, schema = {}) {
|
|
110
|
+
return { name, schema: createBooleanSchema(schema) };
|
|
111
|
+
}
|
|
112
|
+
export function createNullProperty(name, schema = {}) {
|
|
113
|
+
return { name, schema: createNullSchema(schema) };
|
|
114
|
+
}
|
|
115
|
+
export function createNumberProperty(name, schema = {}) {
|
|
116
|
+
return { name, schema: createNumberSchema(schema) };
|
|
117
|
+
}
|
|
118
|
+
export function createIntegerProperty(name, schema = {}) {
|
|
119
|
+
return { name, schema: createIntegerSchema(schema) };
|
|
120
|
+
}
|
|
121
|
+
export function createArrayProperty(name, schema = {}) {
|
|
122
|
+
return { name, schema: createArraySchema(schema) };
|
|
123
|
+
}
|
|
124
|
+
export function createObjectProperty(name, schema = {}) {
|
|
125
|
+
return { name, schema: createObjectSchema(schema) };
|
|
126
|
+
}
|
|
127
|
+
export function createCombinedProperty(name, schema = {}) {
|
|
128
|
+
return { name, schema: createCombinedSchema(schema) };
|
|
129
|
+
}
|
|
130
|
+
export function createUnknownProperty(name, schema = {}) {
|
|
131
|
+
return { name, schema: createUnknownSchema(schema) };
|
|
132
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OpenApiSchema } from '../parse/openapi-types.
|
|
2
|
-
import type { ApiSchema } from '../transform/api-types.
|
|
1
|
+
import type { OpenApiSchema } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { ApiSchema } from '../transform/api-types.ts';
|
|
3
3
|
export declare function resolveAnyOfAndAllOf(schema: ApiSchema<'combined' | 'object'>, ignoreNonObjectParts: boolean): ApiSchema<'object'> | undefined;
|
|
4
4
|
export declare const DEFAULT_IGNORED_SCHEMA_PROPERTIES: (keyof OpenApiSchema)[];
|
|
5
5
|
/**
|
|
@@ -9,4 +9,3 @@ export declare const DEFAULT_IGNORED_SCHEMA_PROPERTIES: (keyof OpenApiSchema)[];
|
|
|
9
9
|
* @param propertiesToIgnore The properties to ignore when checking for a schema definition.
|
|
10
10
|
*/
|
|
11
11
|
export declare function getSchemaReference(schema: ApiSchema, propertiesToIgnore: (keyof OpenApiSchema)[]): ApiSchema;
|
|
12
|
-
//# sourceMappingURL=schema.utils.d.ts.map
|