@goast/core 0.6.0 → 0.7.0-beta.1
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 +23 -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
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# gOAst (@goast/core)
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@goast/core)
|
|
4
|
-
[](https://jsr.io/@goast/core)
|
|
5
4
|
|
|
6
5
|
**gOAst** stands for **g**enerative **O**pen **A**PI **s**pecification **t**ransformer, a tool designed to transform
|
|
7
6
|
OpenAPI specifications into various forms with flexibility and extensibility at its core.
|
|
@@ -58,9 +57,6 @@ main();
|
|
|
58
57
|
|
|
59
58
|
[](https://www.npmjs.com/package/@goast/typescript)
|
|
60
59
|
[](https://www.npmjs.com/package/@goast/kotlin)
|
|
61
|
-
<br>
|
|
62
|
-
[](https://jsr.io/@goast/typescript)
|
|
63
|
-
[](https://jsr.io/@goast/kotlin)
|
|
64
60
|
|
|
65
61
|
## API Documentation 📖
|
|
66
62
|
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from './src/ast/node.ts';
|
|
2
|
+
export * from './src/codegen/config.ts';
|
|
3
|
+
export * from './src/codegen/endpoints-generator.ts';
|
|
4
|
+
export * from './src/codegen/generator.ts';
|
|
5
|
+
export * from './src/codegen/schemas-generator.ts';
|
|
6
|
+
export * from './src/codegen/services-generator.ts';
|
|
7
|
+
export * from './src/codegen/types.ts';
|
|
8
|
+
export * from './src/parse/openapi-types.ts';
|
|
9
|
+
export * from './src/parse/parser.ts';
|
|
10
|
+
export * from './src/parse/types.ts';
|
|
11
|
+
export * from './src/transform/api-types.ts';
|
|
12
|
+
export * from './src/transform/transformer.ts';
|
|
13
|
+
export * from './src/utils/api-data.utils.ts';
|
|
14
|
+
export * from './src/utils/array.utils.ts';
|
|
15
|
+
export * from './src/utils/asset-manager.ts';
|
|
16
|
+
export * from './src/utils/class.utils.ts';
|
|
17
|
+
export * from './src/utils/common.utils.ts';
|
|
18
|
+
export * from './src/utils/endpoint.utils.ts';
|
|
19
|
+
export * from './src/utils/error.utils.ts';
|
|
20
|
+
export * from './src/utils/factory.ts';
|
|
21
|
+
export * from './src/utils/file-system.utils.ts';
|
|
22
|
+
export * from './src/utils/generator.utils.ts';
|
|
23
|
+
export * from './src/utils/object.utils.ts';
|
|
24
|
+
export * from './src/utils/schema.utils.ts';
|
|
25
|
+
export * from './src/utils/source-builder.ts';
|
|
26
|
+
export * from './src/utils/string-builder/options.ts';
|
|
27
|
+
export { type AppendParam, StringBuilder } from './src/utils/string-builder/string-builder.ts';
|
|
28
|
+
export * from './src/utils/string-builder/utils.ts';
|
|
29
|
+
export * from './src/utils/string.utils.ts';
|
|
30
|
+
export * from './src/utils/string.utils.types.ts';
|
|
31
|
+
export * from './src/utils/type.utils.ts';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { StringBuilder } from '../utils/string-builder/string-builder.
|
|
2
|
-
import type { AppendValue } from '../utils/string-builder/utils.
|
|
3
|
-
import type { Prettify } from '../utils/type.utils.
|
|
1
|
+
import type { StringBuilder } from '../utils/string-builder/string-builder.ts';
|
|
2
|
+
import type { AppendValue } from '../utils/string-builder/utils.ts';
|
|
3
|
+
import type { Prettify } from '../utils/type.utils.ts';
|
|
4
4
|
export type AstNodeInject<TBuilder extends StringBuilder, TInjects extends string> = {
|
|
5
5
|
[K in `${'after' | 'before'}${Capitalize<TInjects>}`]?: AppendValue<TBuilder>;
|
|
6
6
|
};
|
|
@@ -14,4 +14,3 @@ export declare abstract class AstNode<TBuilder extends StringBuilder = StringBui
|
|
|
14
14
|
protected getParentNode(builder: TBuilder): AstNode | undefined;
|
|
15
15
|
protected abstract onWrite(builder: TBuilder): void;
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
const NODE_HISTORY_SYMBOL = Symbol('node-history');
|
|
2
2
|
export class AstNode {
|
|
3
|
+
inject;
|
|
3
4
|
constructor(options) {
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(this, "inject", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
this.inject = (_a = options.inject) !== null && _a !== void 0 ? _a : {};
|
|
5
|
+
this.inject = options.inject ?? {};
|
|
12
6
|
}
|
|
13
7
|
write(builder) {
|
|
14
8
|
let history = builder[NODE_HISTORY_SYMBOL];
|
|
@@ -24,6 +18,6 @@ export class AstNode {
|
|
|
24
18
|
}
|
|
25
19
|
getParentNode(builder) {
|
|
26
20
|
const history = builder[NODE_HISTORY_SYMBOL];
|
|
27
|
-
return history
|
|
21
|
+
return history?.at(-2);
|
|
28
22
|
}
|
|
29
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OpenApiParserOptions } from '../parse/types.
|
|
2
|
-
import { type SourceBuilderOptions } from '../utils/source-builder.
|
|
1
|
+
import type { OpenApiParserOptions } from '../parse/types.ts';
|
|
2
|
+
import { type SourceBuilderOptions } from '../utils/source-builder.ts';
|
|
3
3
|
export type OpenApiGeneratorConfig = SourceBuilderOptions & OpenApiParserOptions & {
|
|
4
4
|
/**
|
|
5
5
|
* The directory where the generated files should be saved.
|
|
@@ -33,4 +33,3 @@ export type OpenApiGeneratorConfig = SourceBuilderOptions & OpenApiParserOptions
|
|
|
33
33
|
existingFileBehavior: 'override' | 'skip' | 'error' | 'count';
|
|
34
34
|
};
|
|
35
35
|
export declare const defaultOpenApiGeneratorConfig: OpenApiGeneratorConfig;
|
|
36
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiEndpoint } from '../transform/api-types.
|
|
2
|
-
import type { MaybePromise } from '../utils/type.utils.
|
|
3
|
-
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.
|
|
4
|
-
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.
|
|
1
|
+
import type { ApiEndpoint } from '../transform/api-types.ts';
|
|
2
|
+
import type { MaybePromise } from '../utils/type.utils.ts';
|
|
3
|
+
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.ts';
|
|
4
|
+
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.ts';
|
|
5
5
|
export type OpenApiEndpointsGenerationProviderContext<TInput extends OpenApiGeneratorInput, TOutput extends OpenApiGeneratorOutput, TConfig extends AnyConfig, TEndpointOutput extends OpenApiGeneratorOutput> = OpenApiGenerationProviderContext<TInput, TConfig> & {
|
|
6
6
|
existingEndpointResults: Map<string, TEndpointOutput>;
|
|
7
7
|
output: TOutput;
|
|
@@ -15,4 +15,3 @@ export declare abstract class OpenApiEndpointsGenerationProviderBase<TInput exte
|
|
|
15
15
|
protected abstract addEndpointResult(ctx: TContext, endpoint: ApiEndpoint, result: TEndpointOutput): void;
|
|
16
16
|
protected generateAdditionalFiles(ctx: TContext): MaybePromise<void>;
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=endpoints-generator.d.ts.map
|
|
@@ -24,7 +24,7 @@ export class OpenApiEndpointsGenerationProviderBase extends OpenApiGenerationPro
|
|
|
24
24
|
this.addEndpointResult(ctx, endpoint, result);
|
|
25
25
|
return result;
|
|
26
26
|
}
|
|
27
|
-
//
|
|
27
|
+
// oxlint-disable-next-line no-unused-vars
|
|
28
28
|
generateAdditionalFiles(ctx) {
|
|
29
29
|
// Override if needed
|
|
30
30
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { OpenApiParser } from '../parse/parser.
|
|
2
|
-
import type { ApiData } from '../transform/api-types.
|
|
3
|
-
import { ActionProvider } from '../utils/action-provider.
|
|
4
|
-
import { type DirectoryScanOptions } from '../utils/file-system.utils.
|
|
5
|
-
import type { EmptyConstructor, Merge } from '../utils/type.utils.
|
|
6
|
-
import { type OpenApiGeneratorConfig } from './config.
|
|
7
|
-
import type { AnyConfig, OpenApiGenerationProvider, OpenApiGenerationProviderContext, OpenApiGenerationProviderFn, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.
|
|
1
|
+
import { OpenApiParser } from '../parse/parser.ts';
|
|
2
|
+
import type { ApiData } from '../transform/api-types.ts';
|
|
3
|
+
import { ActionProvider } from '../utils/action-provider.ts';
|
|
4
|
+
import { type DirectoryScanOptions } from '../utils/file-system.utils.ts';
|
|
5
|
+
import type { EmptyConstructor, Merge } from '../utils/type.utils.ts';
|
|
6
|
+
import { type OpenApiGeneratorConfig } from './config.ts';
|
|
7
|
+
import type { AnyConfig, OpenApiGenerationProvider, OpenApiGenerationProviderContext, OpenApiGenerationProviderFn, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.ts';
|
|
8
8
|
type OpenApiGenerationProviders = {
|
|
9
9
|
provider: ActionProvider<OpenApiGenerationProviderFn>;
|
|
10
10
|
config: AnyConfig | undefined;
|
|
@@ -36,4 +36,3 @@ export declare abstract class OpenApiGenerationProviderBase<TInput extends OpenA
|
|
|
36
36
|
protected abstract onGenerate(ctx: TContext): TOutput | Promise<TOutput>;
|
|
37
37
|
}
|
|
38
38
|
export {};
|
|
39
|
-
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -5,31 +5,15 @@ import { ActionProvider } from '../utils/action-provider.js';
|
|
|
5
5
|
import { getFiles } from '../utils/file-system.utils.js';
|
|
6
6
|
import { defaultOpenApiGeneratorConfig } from './config.js';
|
|
7
7
|
class _OpenApiGenerator {
|
|
8
|
+
_providers;
|
|
9
|
+
_config;
|
|
10
|
+
_parser;
|
|
8
11
|
constructor(config, providers, parser) {
|
|
9
|
-
Object.defineProperty(this, "_providers", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: void 0
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "_config", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "_parser", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
12
|
this._providers = providers;
|
|
28
13
|
this._config = config;
|
|
29
14
|
this._parser = parser;
|
|
30
15
|
}
|
|
31
16
|
use(provider, config) {
|
|
32
|
-
// deno-lint-ignore no-explicit-any
|
|
33
17
|
this._providers.push({ provider: provider, config });
|
|
34
18
|
return new _OpenApiGenerator(this._config, [...this._providers], this._parser);
|
|
35
19
|
}
|
|
@@ -80,11 +64,10 @@ class _OpenApiGenerator {
|
|
|
80
64
|
return await this.generate(data);
|
|
81
65
|
}
|
|
82
66
|
async parseAndGenerateFromDir(dir, options) {
|
|
83
|
-
const filter = (file) =>
|
|
67
|
+
const filter = (file) => (file.endsWith('.yml') || file.endsWith('.yaml') || file.endsWith('.json')) && (options?.filter?.(file) ?? true);
|
|
84
68
|
return this.parseAndGenerate(...(await getFiles(dir, { ...options, filter })));
|
|
85
69
|
}
|
|
86
70
|
}
|
|
87
|
-
// deno-lint-ignore ban-types
|
|
88
71
|
export class OpenApiGenerator extends _OpenApiGenerator {
|
|
89
72
|
constructor(config) {
|
|
90
73
|
super({ ...defaultOpenApiGeneratorConfig, ...config }, [], new OpenApiParser({ ...defaultOpenApiGeneratorConfig, ...config }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiSchema } from '../transform/api-types.
|
|
2
|
-
import type { MaybePromise } from '../utils/type.utils.
|
|
3
|
-
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.
|
|
4
|
-
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.
|
|
1
|
+
import type { ApiSchema } from '../transform/api-types.ts';
|
|
2
|
+
import type { MaybePromise } from '../utils/type.utils.ts';
|
|
3
|
+
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.ts';
|
|
4
|
+
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.ts';
|
|
5
5
|
export type OpenApiSchemasGenerationProviderContext<TInput extends OpenApiGeneratorInput, TOutput extends OpenApiGeneratorOutput, TConfig extends AnyConfig, TSchemaOutput extends OpenApiGeneratorOutput> = OpenApiGenerationProviderContext<TInput, TConfig> & {
|
|
6
6
|
existingSchemaResults: Map<string, TSchemaOutput>;
|
|
7
7
|
output: TOutput;
|
|
@@ -16,4 +16,3 @@ export declare abstract class OpenApiSchemasGenerationProviderBase<TInput extend
|
|
|
16
16
|
protected abstract addSchemaResult(ctx: TContext, schema: ApiSchema, result: TSchemaOutput): void;
|
|
17
17
|
protected generateAdditionalFiles(ctx: TContext): MaybePromise<void>;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=schemas-generator.d.ts.map
|
|
@@ -33,12 +33,11 @@ export class OpenApiSchemasGenerationProviderBase extends OpenApiGenerationProvi
|
|
|
33
33
|
this.addSchemaResult(ctx, schema, result);
|
|
34
34
|
return result;
|
|
35
35
|
}
|
|
36
|
-
// deno-lint-ignore no-unused-vars
|
|
37
36
|
getSchemaReference(ctx, schema) {
|
|
38
37
|
const ref = getSchemaReference(schema, ['description']);
|
|
39
38
|
return ref.id !== schema.id ? ref : undefined;
|
|
40
39
|
}
|
|
41
|
-
//
|
|
40
|
+
// oxlint-disable-next-line no-unused-vars
|
|
42
41
|
generateAdditionalFiles(ctx) {
|
|
43
42
|
// Override if needed
|
|
44
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiService } from '../transform/api-types.
|
|
2
|
-
import type { MaybePromise } from '../utils/type.utils.
|
|
3
|
-
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.
|
|
4
|
-
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.
|
|
1
|
+
import type { ApiService } from '../transform/api-types.ts';
|
|
2
|
+
import type { MaybePromise } from '../utils/type.utils.ts';
|
|
3
|
+
import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.ts';
|
|
4
|
+
import type { AnyConfig, OpenApiGenerationProviderContext, OpenApiGeneratorContext, OpenApiGeneratorInput, OpenApiGeneratorOutput } from './types.ts';
|
|
5
5
|
export type OpenApiServicesGenerationProviderContext<TInput extends OpenApiGeneratorInput, TOutput extends OpenApiGeneratorOutput, TConfig extends AnyConfig, TServiceOutput extends OpenApiGeneratorOutput> = OpenApiGenerationProviderContext<TInput, TConfig> & {
|
|
6
6
|
existingServiceResults: Map<string, TServiceOutput>;
|
|
7
7
|
output: TOutput;
|
|
@@ -15,4 +15,3 @@ export declare abstract class OpenApiServicesGenerationProviderBase<TInput exten
|
|
|
15
15
|
protected abstract addServiceResult(ctx: TContext, service: ApiService, result: TServiceOutput): void;
|
|
16
16
|
protected generateAdditionalFiles(ctx: TContext): MaybePromise<void>;
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=services-generator.d.ts.map
|
|
@@ -24,7 +24,7 @@ export class OpenApiServicesGenerationProviderBase extends OpenApiGenerationProv
|
|
|
24
24
|
this.addServiceResult(ctx, service, result);
|
|
25
25
|
return result;
|
|
26
26
|
}
|
|
27
|
-
//
|
|
27
|
+
// oxlint-disable-next-line no-unused-vars
|
|
28
28
|
generateAdditionalFiles(ctx) {
|
|
29
29
|
// Override if needed
|
|
30
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiData } from '../transform/api-types.
|
|
2
|
-
import type { MaybePromise } from '../utils/type.utils.
|
|
3
|
-
import type { OpenApiGeneratorConfig } from './config.
|
|
1
|
+
import type { ApiData } from '../transform/api-types.ts';
|
|
2
|
+
import type { MaybePromise } from '../utils/type.utils.ts';
|
|
3
|
+
import type { OpenApiGeneratorConfig } from './config.ts';
|
|
4
4
|
export type AnyConfig = Readonly<Record<string, unknown>>;
|
|
5
5
|
export type OpenApiGeneratorInput = Record<string, unknown>;
|
|
6
6
|
export type OpenApiGeneratorOutput = Record<string, unknown> | undefined;
|
|
@@ -16,4 +16,3 @@ export interface OpenApiGenerationProvider<TInput extends OpenApiGeneratorInput
|
|
|
16
16
|
generate(...args: Parameters<OpenApiGenerationProviderFn<TInput, TOutput, TConfig>>): ReturnType<OpenApiGenerationProviderFn<TInput, TOutput, TConfig>>;
|
|
17
17
|
}
|
|
18
18
|
export type OpenApiGenerationProviderFn<TInput extends OpenApiGeneratorInput = OpenApiGeneratorInput, TOutput extends OpenApiGeneratorOutput = OpenApiGeneratorOutput, TConfig extends AnyConfig = AnyConfig> = (context: OpenApiGeneratorContext<TInput>, config?: Partial<TConfig>) => MaybePromise<TOutput>;
|
|
19
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -11,17 +11,16 @@ export function collectOpenApi(apis) {
|
|
|
11
11
|
const jsonSchemaProperties = ['$id', 'allOf', 'anyOf', 'oneOf', 'enum', 'not', 'properties', 'title', 'type'];
|
|
12
12
|
function collectDocument(data, documents) {
|
|
13
13
|
collect(data, documents, (data, document) => {
|
|
14
|
-
var _a, _b, _c, _d, _e;
|
|
15
14
|
data.documents.push(document);
|
|
16
15
|
collectPaths(data, document.paths);
|
|
17
|
-
collectRecord(data,
|
|
16
|
+
collectRecord(data, document.components?.schemas, collectSchema);
|
|
18
17
|
collectRecord(data, document.definitions, collectSchema);
|
|
19
|
-
collectRecord(data,
|
|
18
|
+
collectRecord(data, document.components?.parameters, collectParameter);
|
|
20
19
|
collectRecord(data, document.parameters, collectParameter);
|
|
21
|
-
collectRecord(data,
|
|
22
|
-
collectRecord(data,
|
|
20
|
+
collectRecord(data, document.components?.requestBodies, collectRequestBody);
|
|
21
|
+
collectRecord(data, document.components?.responses, collectResponse);
|
|
23
22
|
collectRecord(data, document.responses, collectResponse);
|
|
24
|
-
collectRecord(data,
|
|
23
|
+
collectRecord(data, document.components?.headers, collectHeader);
|
|
25
24
|
if (Object.keys(document).some((key) => jsonSchemaProperties.includes(key))) {
|
|
26
25
|
collectSchema(data, document);
|
|
27
26
|
}
|
|
@@ -56,7 +55,6 @@ function collectPathItem(data, pathItems, path) {
|
|
|
56
55
|
}
|
|
57
56
|
function collectSchema(data, schemas) {
|
|
58
57
|
collect(data, schemas, (data, schema) => {
|
|
59
|
-
var _a;
|
|
60
58
|
const key = `${schema.$src.file}#${schema.$src.path}`;
|
|
61
59
|
if (data.schemas.has(key))
|
|
62
60
|
return;
|
|
@@ -77,7 +75,7 @@ function collectSchema(data, schemas) {
|
|
|
77
75
|
collectSchema(data, schema.additionalItems);
|
|
78
76
|
}
|
|
79
77
|
if (typeof schema.discriminator === 'object') {
|
|
80
|
-
collectRecord(data,
|
|
78
|
+
collectRecord(data, schema.discriminator?.mapping, collectSchema);
|
|
81
79
|
}
|
|
82
80
|
});
|
|
83
81
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from '../utils/type.utils.
|
|
2
|
-
import type { OpenApiCollectorData } from './types.
|
|
1
|
+
import type { Nullable } from '../utils/type.utils.ts';
|
|
2
|
+
import type { OpenApiCollectorData } from './types.ts';
|
|
3
3
|
export declare function collect<T extends Record<`x-${string}`, unknown>>(data: OpenApiCollectorData, obj: Nullable<T | Nullable<T>[]>, func: (data: OpenApiCollectorData, obj: NonNullable<T>) => void): void;
|
|
4
4
|
export declare function collectRecord<T extends Record<`x-${string}`, unknown>>(data: OpenApiCollectorData, obj: Nullable<Record<string, Nullable<T>>>, func: (data: OpenApiCollectorData, obj: NonNullable<T>, key: string) => void): void;
|
|
5
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OpenApiDocument, OpenApiHttpMethod, OpenApiOperation, OpenApiPathItem, OpenApiSchema } from '../parse/openapi-types.
|
|
2
|
-
import type { Deref } from '../parse/types.
|
|
1
|
+
import type { OpenApiDocument, OpenApiHttpMethod, OpenApiOperation, OpenApiPathItem, OpenApiSchema } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { Deref } from '../parse/types.ts';
|
|
3
3
|
export type OpenApiCollectorEndpointInfo = {
|
|
4
4
|
path: string;
|
|
5
5
|
method: OpenApiHttpMethod;
|
|
@@ -11,4 +11,3 @@ export type OpenApiCollectorData = {
|
|
|
11
11
|
schemas: Map<string, Deref<OpenApiSchema>>;
|
|
12
12
|
endpoints: Map<string, OpenApiCollectorEndpointInfo>;
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -4,28 +4,14 @@ export function createDerefProxy(obj, source, ref) {
|
|
|
4
4
|
}
|
|
5
5
|
const propertiesNotDerivedFromRef = ['title'];
|
|
6
6
|
class DerefProxyHandler {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "_ref", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: _ref
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "_overwrittenValues", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: {}
|
|
25
|
-
});
|
|
7
|
+
_overwrittenValues = {};
|
|
8
|
+
_source;
|
|
9
|
+
_ref;
|
|
10
|
+
constructor(source, ref) {
|
|
11
|
+
this._source = source;
|
|
12
|
+
this._ref = ref;
|
|
26
13
|
}
|
|
27
14
|
get(target, prop) {
|
|
28
|
-
var _a;
|
|
29
15
|
if (prop === '$ref') {
|
|
30
16
|
return this._ref;
|
|
31
17
|
}
|
|
@@ -40,7 +26,7 @@ class DerefProxyHandler {
|
|
|
40
26
|
}
|
|
41
27
|
return propertiesNotDerivedFromRef.includes(prop)
|
|
42
28
|
? undefined
|
|
43
|
-
:
|
|
29
|
+
: this._ref?.[prop];
|
|
44
30
|
}
|
|
45
31
|
set(_target, prop, value) {
|
|
46
32
|
if (prop === '$ref' && (typeof value === 'object' || typeof value === 'undefined')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiData } from '../transform/api-types.
|
|
2
|
-
import type { OpenApiDocument } from './openapi-types.
|
|
3
|
-
import { type Deref, type OpenApiParserOptions } from './types.
|
|
1
|
+
import type { ApiData } from '../transform/api-types.ts';
|
|
2
|
+
import type { OpenApiDocument } from './openapi-types.ts';
|
|
3
|
+
import { type Deref, type OpenApiParserOptions } from './types.ts';
|
|
4
4
|
export declare class OpenApiParser {
|
|
5
5
|
private readonly _loadedDocuments;
|
|
6
6
|
private readonly _config;
|
|
@@ -15,4 +15,3 @@ export declare class OpenApiParser {
|
|
|
15
15
|
private isUrl;
|
|
16
16
|
private tryParseYamlOrJson;
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as dntShim from "../../_dnt.shims.js";
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { cwd } from 'node:process';
|
|
4
3
|
import fs from 'fs-extra';
|
|
@@ -9,19 +8,9 @@ import { getLineInfo, parseYamlWithInfo } from '../utils/yaml-info.js';
|
|
|
9
8
|
import { createDerefProxy } from './deref-proxy.js';
|
|
10
9
|
import { defaultOpenApiParserOptions } from './types.js';
|
|
11
10
|
export class OpenApiParser {
|
|
11
|
+
_loadedDocuments = new Map();
|
|
12
|
+
_config;
|
|
12
13
|
constructor(config) {
|
|
13
|
-
Object.defineProperty(this, "_loadedDocuments", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: new Map()
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "_config", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
14
|
this._config = { ...defaultOpenApiParserOptions, ...config };
|
|
26
15
|
}
|
|
27
16
|
async parseApisAndTransform(...fileNames) {
|
|
@@ -61,8 +50,7 @@ export class OpenApiParser {
|
|
|
61
50
|
});
|
|
62
51
|
existingDocument.dereferencedComponents.set(openApiPath, result);
|
|
63
52
|
if (value.$ref) {
|
|
64
|
-
|
|
65
|
-
result.$ref = await this.resolveReference(file, value);
|
|
53
|
+
result.$ref = (await this.resolveReference(file, value));
|
|
66
54
|
}
|
|
67
55
|
for (const key of Object.keys(value)) {
|
|
68
56
|
if (key === '$ref')
|
|
@@ -92,7 +80,6 @@ export class OpenApiParser {
|
|
|
92
80
|
return result;
|
|
93
81
|
}
|
|
94
82
|
async resolveReference(file, ref) {
|
|
95
|
-
var _a;
|
|
96
83
|
const [refFile, refPath] = ref.$ref.split('#');
|
|
97
84
|
let absoluteRefFile = refFile;
|
|
98
85
|
if (!/\S/.test(refFile)) {
|
|
@@ -104,7 +91,7 @@ export class OpenApiParser {
|
|
|
104
91
|
const doc = await this.loadDocument(absoluteRefFile);
|
|
105
92
|
const value = refPath ? getDeepProperty(doc.document, refPath.replace(/[/]/g, '.')) : doc.document;
|
|
106
93
|
if (value && typeof value === 'object') {
|
|
107
|
-
return this.dereference(absoluteRefFile,
|
|
94
|
+
return this.dereference(absoluteRefFile, refPath?.split('/').filter(Boolean) ?? [], value);
|
|
108
95
|
}
|
|
109
96
|
return undefined;
|
|
110
97
|
}
|
|
@@ -118,7 +105,7 @@ export class OpenApiParser {
|
|
|
118
105
|
if (parsedDocument === undefined) {
|
|
119
106
|
throw new Error(`Unable to parse ${fileOrUrl}`);
|
|
120
107
|
}
|
|
121
|
-
const doc = (parsedDocument
|
|
108
|
+
const doc = (parsedDocument ?? {});
|
|
122
109
|
const deref = createDerefProxy(doc, {
|
|
123
110
|
file: fileOrUrl,
|
|
124
111
|
pos: { line: 0, col: 0 },
|
|
@@ -139,7 +126,7 @@ export class OpenApiParser {
|
|
|
139
126
|
}
|
|
140
127
|
async getDocumentContent(fileOrUrl) {
|
|
141
128
|
if (this.isUrl(fileOrUrl)) {
|
|
142
|
-
const res = await
|
|
129
|
+
const res = await fetch(fileOrUrl);
|
|
143
130
|
if (!res.ok) {
|
|
144
131
|
throw new Error(`Unable to download ${fileOrUrl}: ${res.statusText}`);
|
|
145
132
|
}
|
|
@@ -156,7 +143,7 @@ export class OpenApiParser {
|
|
|
156
143
|
try {
|
|
157
144
|
return parseYamlWithInfo(yamlOrJson);
|
|
158
145
|
}
|
|
159
|
-
catch
|
|
146
|
+
catch {
|
|
160
147
|
return undefined;
|
|
161
148
|
}
|
|
162
149
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type OpenApiTransformerOptions } from '../transform/types.
|
|
2
|
-
import type { OpenApiDiscriminator, OpenApiDocument, OpenApiReference, OpenApiSchema } from './openapi-types.
|
|
1
|
+
import { type OpenApiTransformerOptions } from '../transform/types.ts';
|
|
2
|
+
import type { OpenApiDiscriminator, OpenApiDocument, OpenApiReference, OpenApiSchema } from './openapi-types.ts';
|
|
3
3
|
export type DerefSource<T> = {
|
|
4
4
|
file: string;
|
|
5
5
|
pos: {
|
|
@@ -22,7 +22,6 @@ type _Deref<T extends object> = T extends OpenApiDiscriminator ? _DerefDiscrimin
|
|
|
22
22
|
export type Deref<T> = T extends object ? (T extends (infer A)[] ? Deref<A>[] : _Deref<T>) : T;
|
|
23
23
|
export type OpenApiParserOptions = OpenApiTransformerOptions;
|
|
24
24
|
export declare const defaultOpenApiParserOptions: {
|
|
25
|
-
unknownTypeBehavior:
|
|
25
|
+
unknownTypeBehavior: 'keep-unknown' | 'object-if-properties' | 'always-object';
|
|
26
26
|
};
|
|
27
27
|
export {};
|
|
28
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { KnownOpenApiParameterTarget, OpenApiDocument, OpenApiHeader, OpenApiHttpMethod, OpenApiMediaType, OpenApiOperation, OpenApiParameter, OpenApiPathItem, OpenApiRequestBody, OpenApiResponse, OpenApiSchema, OpenApiTag } from '../parse/openapi-types.
|
|
2
|
-
import type { Deref, DerefSource } from '../parse/types.
|
|
3
|
-
import type { OptionalProperties } from '../utils/type.utils.
|
|
1
|
+
import type { KnownOpenApiParameterTarget, OpenApiDocument, OpenApiHeader, OpenApiHttpMethod, OpenApiMediaType, OpenApiOperation, OpenApiParameter, OpenApiPathItem, OpenApiRequestBody, OpenApiResponse, OpenApiSchema, OpenApiTag } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { Deref, DerefSource } from '../parse/types.ts';
|
|
3
|
+
import type { OptionalProperties } from '../utils/type.utils.ts';
|
|
4
4
|
export type ApiData = {
|
|
5
5
|
documents: Deref<OpenApiDocument>[];
|
|
6
6
|
services: ApiService[];
|
|
@@ -208,4 +208,3 @@ export type PrimitiveLikeApiSchema = ApiSchemaBase & {
|
|
|
208
208
|
type: 'string' | 'number' | 'integer' | 'boolean' | 'null' | string[];
|
|
209
209
|
} & AdditionalPrimitiveSchemaProperties;
|
|
210
210
|
export {};
|
|
211
|
-
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { OpenApiObject } from '../parse/openapi-types.
|
|
2
|
-
import type { Deref, DerefSource } from '../parse/types.
|
|
3
|
-
import type { ApiSchema, ApiSchemaAccessibility, ApiSchemaKind, ApiSchemaProperty } from './api-types.
|
|
4
|
-
import type { OpenApiTransformerContext } from './types.
|
|
1
|
+
import type { OpenApiObject } from '../parse/openapi-types.ts';
|
|
2
|
+
import type { Deref, DerefSource } from '../parse/types.ts';
|
|
3
|
+
import type { ApiSchema, ApiSchemaAccessibility, ApiSchemaKind, ApiSchemaProperty } from './api-types.ts';
|
|
4
|
+
import type { OpenApiTransformerContext } from './types.ts';
|
|
5
5
|
/** Normalizes a `type` keyword to an array, so a scalar type and a 3.1 type array can be treated alike. */
|
|
6
6
|
export declare function asTypeArray(type: string | string[] | undefined | null): string[];
|
|
7
7
|
/** The declared types with every `null` member removed. */
|
|
@@ -55,4 +55,3 @@ export declare class IdGenerator {
|
|
|
55
55
|
}
|
|
56
56
|
export declare function getOpenApiObjectIdentifier(obj: Deref<OpenApiObject<string>>): string;
|
|
57
57
|
export {};
|
|
58
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -37,8 +37,7 @@ export function determineSchemaKind(ctx, schema) {
|
|
|
37
37
|
return 'oneOf';
|
|
38
38
|
}
|
|
39
39
|
else if (!narrowsToSingleType && schema.type !== 'object' && (schema.allOf || schema.anyOf)) {
|
|
40
|
-
const hasProperties = (schema.properties && Object.keys(schema.properties).length > 0) ||
|
|
41
|
-
schema.additionalProperties;
|
|
40
|
+
const hasProperties = (schema.properties && Object.keys(schema.properties).length > 0) || schema.additionalProperties;
|
|
42
41
|
return hasProperties ? 'object' : 'combined';
|
|
43
42
|
}
|
|
44
43
|
else if (Array.isArray(schema.type)) {
|
|
@@ -60,7 +59,6 @@ export function determineSchemaKind(ctx, schema) {
|
|
|
60
59
|
return treadAsObject ? 'object' : 'unknown';
|
|
61
60
|
}
|
|
62
61
|
export function determineSchemaName(schema, id) {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f;
|
|
64
62
|
if (schema.title)
|
|
65
63
|
return { name: schema.title, isGenerated: false };
|
|
66
64
|
if (schema.$src.path === '/')
|
|
@@ -76,7 +74,7 @@ export function determineSchemaName(schema, id) {
|
|
|
76
74
|
const responseMatch = schema.$src.path.match(/\/paths\/(?<path>.+)\/(?<method>.+)\/responses\/(?<status>\d+)\//);
|
|
77
75
|
if (responseMatch && responseMatch.groups) {
|
|
78
76
|
const { path, method, status } = responseMatch.groups;
|
|
79
|
-
const operation =
|
|
77
|
+
const operation = schema.$src.document.paths?.[path]?.[method] ?? {};
|
|
80
78
|
return {
|
|
81
79
|
name: `${determineEndpointName({ method, path: `/${path}`, operation })}_${status}_Response`,
|
|
82
80
|
isGenerated: true,
|
|
@@ -94,7 +92,7 @@ export function determineSchemaName(schema, id) {
|
|
|
94
92
|
const requestBodyMatch = schema.$src.path.match(/\/paths\/(?<path>.+)\/(?<method>.+)\/requestBody\//);
|
|
95
93
|
if (requestBodyMatch && requestBodyMatch.groups) {
|
|
96
94
|
const { path, method } = requestBodyMatch.groups;
|
|
97
|
-
const operation =
|
|
95
|
+
const operation = schema.$src.document.paths?.[path]?.[method] ?? {};
|
|
98
96
|
return { name: `${determineEndpointName({ method, path: `/${path}`, operation })}_Request`, isGenerated: true };
|
|
99
97
|
}
|
|
100
98
|
const parentSchemaMatch = schema.$src.path.match(/(.*)\/properties\/([^/]*)(\/additionalProperties)?$/);
|
|
@@ -175,17 +173,9 @@ export function transformSchemaProperties(context, schema, transformSchema) {
|
|
|
175
173
|
return result;
|
|
176
174
|
}
|
|
177
175
|
export class IdGenerator {
|
|
178
|
-
|
|
179
|
-
Object.defineProperty(this, "_idMap", {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
configurable: true,
|
|
182
|
-
writable: true,
|
|
183
|
-
value: new Map()
|
|
184
|
-
});
|
|
185
|
-
}
|
|
176
|
+
_idMap = new Map();
|
|
186
177
|
generateId(name) {
|
|
187
|
-
|
|
188
|
-
const id = (_a = this._idMap.get(name)) !== null && _a !== void 0 ? _a : 1;
|
|
178
|
+
const id = this._idMap.get(name) ?? 1;
|
|
189
179
|
this._idMap.set(name, id + 1);
|
|
190
180
|
return `${name}-${id}`;
|
|
191
181
|
}
|