@goast/core 0.4.2 → 0.5.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.
Files changed (71) hide show
  1. package/LICENSE +21 -21
  2. package/esm/mod.d.ts +1 -0
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/mod.js +1 -0
  5. package/esm/src/codegen/config.d.ts +11 -0
  6. package/esm/src/codegen/config.d.ts.map +1 -1
  7. package/esm/src/codegen/config.js +1 -0
  8. package/esm/src/utils/file-system.utils.d.ts +2 -0
  9. package/esm/src/utils/file-system.utils.d.ts.map +1 -1
  10. package/esm/src/utils/file-system.utils.js +11 -1
  11. package/esm/src/utils/schema.utils.d.ts +1 -0
  12. package/esm/src/utils/schema.utils.d.ts.map +1 -1
  13. package/esm/src/utils/schema.utils.js +5 -0
  14. package/package.json +2 -2
  15. package/script/mod.d.ts +1 -0
  16. package/script/mod.d.ts.map +1 -1
  17. package/script/mod.js +1 -0
  18. package/script/src/codegen/config.d.ts +11 -0
  19. package/script/src/codegen/config.d.ts.map +1 -1
  20. package/script/src/codegen/config.js +1 -0
  21. package/script/src/utils/file-system.utils.d.ts +2 -0
  22. package/script/src/utils/file-system.utils.d.ts.map +1 -1
  23. package/script/src/utils/file-system.utils.js +11 -0
  24. package/script/src/utils/schema.utils.d.ts +1 -0
  25. package/script/src/utils/schema.utils.d.ts.map +1 -1
  26. package/script/src/utils/schema.utils.js +6 -0
  27. package/src/_dnt.shims.ts +0 -69
  28. package/src/mod.ts +0 -33
  29. package/src/src/ast/node.ts +0 -46
  30. package/src/src/codegen/config.ts +0 -28
  31. package/src/src/codegen/endpoints-generator.ts +0 -72
  32. package/src/src/codegen/generator.ts +0 -181
  33. package/src/src/codegen/internal-utils.ts +0 -6
  34. package/src/src/codegen/schemas-generator.ts +0 -87
  35. package/src/src/codegen/services-generator.ts +0 -77
  36. package/src/src/codegen/types.ts +0 -37
  37. package/src/src/collect/collector.ts +0 -142
  38. package/src/src/collect/helpers.ts +0 -36
  39. package/src/src/collect/types.ts +0 -21
  40. package/src/src/internal-utils.ts +0 -5
  41. package/src/src/parse/deref-proxy.ts +0 -64
  42. package/src/src/parse/openapi-types.ts +0 -949
  43. package/src/src/parse/parser.ts +0 -220
  44. package/src/src/parse/types.ts +0 -27
  45. package/src/src/transform/api-types.ts +0 -243
  46. package/src/src/transform/helpers.ts +0 -216
  47. package/src/src/transform/transform-document.ts +0 -35
  48. package/src/src/transform/transform-endpoint.ts +0 -331
  49. package/src/src/transform/transform-schema.ts +0 -217
  50. package/src/src/transform/transformer.ts +0 -52
  51. package/src/src/transform/types.ts +0 -52
  52. package/src/src/utils/action-provider.ts +0 -58
  53. package/src/src/utils/array.utils.ts +0 -7
  54. package/src/src/utils/asset-manager.ts +0 -51
  55. package/src/src/utils/class.utils.ts +0 -40
  56. package/src/src/utils/common.utils.ts +0 -86
  57. package/src/src/utils/condition.ts +0 -7
  58. package/src/src/utils/endpoint.utils.ts +0 -10
  59. package/src/src/utils/error.utils.ts +0 -3
  60. package/src/src/utils/factory.ts +0 -42
  61. package/src/src/utils/file-system.utils.ts +0 -48
  62. package/src/src/utils/generator.utils.ts +0 -6
  63. package/src/src/utils/object.utils.ts +0 -32
  64. package/src/src/utils/schema.utils.ts +0 -142
  65. package/src/src/utils/source-builder.ts +0 -597
  66. package/src/src/utils/string-builder/options.ts +0 -19
  67. package/src/src/utils/string-builder/string-builder.ts +0 -165
  68. package/src/src/utils/string-builder/utils.ts +0 -69
  69. package/src/src/utils/string.utils.ts +0 -369
  70. package/src/src/utils/string.utils.types.ts +0 -179
  71. package/src/src/utils/type.utils.ts +0 -93
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Marc Schmidt
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Marc Schmidt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/esm/mod.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './src/utils/common.utils.js';
17
17
  export * from './src/utils/endpoint.utils.js';
18
18
  export * from './src/utils/error.utils.js';
19
19
  export * from './src/utils/factory.js';
20
+ export * from './src/utils/file-system.utils.js';
20
21
  export * from './src/utils/generator.utils.js';
21
22
  export * from './src/utils/object.utils.js';
22
23
  export * from './src/utils/schema.utils.js';
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC/F,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC/F,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
package/esm/mod.js CHANGED
@@ -17,6 +17,7 @@ export * from './src/utils/common.utils.js';
17
17
  export * from './src/utils/endpoint.utils.js';
18
18
  export * from './src/utils/error.utils.js';
19
19
  export * from './src/utils/factory.js';
20
+ export * from './src/utils/file-system.utils.js';
20
21
  export * from './src/utils/generator.utils.js';
21
22
  export * from './src/utils/object.utils.js';
22
23
  export * from './src/utils/schema.utils.js';
@@ -11,6 +11,17 @@ export type OpenApiGeneratorConfig = SourceBuilderOptions & OpenApiParserOptions
11
11
  * @default true
12
12
  */
13
13
  clearOutputDir: boolean;
14
+ /**
15
+ * How to handle existing files in the output directory.
16
+ * - 'override': overwrite existing files.
17
+ * - 'skip': skip generating files that already exist.
18
+ * - 'error': throw an error if a file already exists.
19
+ *
20
+ * Is is recommended to use `'error'` to prevent issues of two schemas generating the same file and overwriting each other.
21
+ * If `clearOutputDir` is set to `false`, it is recommended to use `'override'` to ensure that the generated files are up to date.
22
+ * @default 'error'
23
+ */
24
+ existingFileBehavior: 'override' | 'skip' | 'error';
14
25
  };
15
26
  export declare const defaultOpenApiGeneratorConfig: OpenApiGeneratorConfig;
16
27
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/codegen/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,MAAM,MAAM,sBAAsB,GAC9B,oBAAoB,GACpB,oBAAoB,GACpB;IACA;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEJ,eAAO,MAAM,6BAA6B,EAAE,sBAM3C,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/codegen/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,MAAM,MAAM,sBAAsB,GAC9B,oBAAoB,GACpB,oBAAoB,GACpB;IACA;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;;;;;;OASG;IACH,oBAAoB,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;CACrD,CAAC;AAEJ,eAAO,MAAM,6BAA6B,EAAE,sBAO3C,CAAC"}
@@ -5,4 +5,5 @@ export const defaultOpenApiGeneratorConfig = {
5
5
  ...defaultOpenApiTransformerOptions,
6
6
  outputDir: 'generated',
7
7
  clearOutputDir: true,
8
+ existingFileBehavior: 'error',
8
9
  };
@@ -1,3 +1,4 @@
1
+ import type { OpenApiGeneratorConfig } from '../codegen/config.js';
1
2
  import type { Nullable } from './type.utils.js';
2
3
  export type DirectoryScanOptions = {
3
4
  recursive: boolean;
@@ -6,4 +7,5 @@ export type DirectoryScanOptions = {
6
7
  };
7
8
  export declare const defaultDirectoryScanOptions: DirectoryScanOptions;
8
9
  export declare function getFiles(dir: string, options?: Partial<DirectoryScanOptions>): Promise<string[]>;
10
+ export declare function writeGeneratedFile(config: OpenApiGeneratorConfig, filePath: string, content: string): void;
9
11
  //# sourceMappingURL=file-system.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-system.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/file-system.utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,oBAGzC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKtG"}
1
+ {"version":3,"file":"file-system.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/file-system.utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,oBAGzC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKtG;AA0BD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAU1G"}
@@ -1,4 +1,4 @@
1
- import { resolve } from 'node:path';
1
+ import { dirname, resolve } from 'node:path';
2
2
  import fs from 'fs-extra';
3
3
  export const defaultDirectoryScanOptions = {
4
4
  recursive: false,
@@ -29,3 +29,13 @@ async function getFilesImpl(dir, options, files, currentDepth) {
29
29
  }
30
30
  }
31
31
  }
32
+ export function writeGeneratedFile(config, filePath, content) {
33
+ if (config.existingFileBehavior !== 'override' && fs.existsSync(filePath)) {
34
+ if (config.existingFileBehavior === 'error') {
35
+ throw new Error(`File already exists: ${filePath}`);
36
+ }
37
+ return;
38
+ }
39
+ fs.ensureDirSync(dirname(filePath));
40
+ fs.writeFileSync(filePath, content);
41
+ }
@@ -1,6 +1,7 @@
1
1
  import type { OpenApiSchema } from '../parse/openapi-types.js';
2
2
  import type { ApiSchema } from '../transform/api-types.js';
3
3
  export declare function resolveAnyOfAndAllOf(schema: ApiSchema<'combined' | 'object'>, ignoreNonObjectParts: boolean): ApiSchema<'object'> | undefined;
4
+ export declare const DEFAULT_IGNORED_SCHEMA_PROPERTIES: (keyof OpenApiSchema)[];
4
5
  /**
5
6
  * Retrieves the first schema reference and the reference chain of a given schema that
6
7
  * defines some schema properties. (e.g. schemas with just "$ref" are skipped)
@@ -1 +1 @@
1
- {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/schema.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAA0C,MAAM,2BAA2B,CAAC;AAEnG,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,UAAU,GAAG,QAAQ,CAAC,EACxC,oBAAoB,EAAE,OAAO,GAC5B,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAgCjC;AA0FD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG,SAAS,CAM5G"}
1
+ {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/schema.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAA0C,MAAM,2BAA2B,CAAC;AAEnG,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,UAAU,GAAG,QAAQ,CAAC,EACxC,oBAAoB,EAAE,OAAO,GAC5B,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAgCjC;AA0FD,eAAO,MAAM,iCAAiC,EAAE,CAAC,MAAM,aAAa,CAAC,EAIpE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG,SAAS,CAM5G"}
@@ -102,6 +102,11 @@ function hasInvalidSubSchema(subSchemas) {
102
102
  return subSchemas.some((x) => x.kind !== 'object' &&
103
103
  (x.kind !== 'combined' || (!hasInvalidSubSchema(x.allOf) && !hasInvalidSubSchema(x.anyOf))));
104
104
  }
105
+ export const DEFAULT_IGNORED_SCHEMA_PROPERTIES = [
106
+ 'description',
107
+ 'example',
108
+ 'deprecated',
109
+ ];
105
110
  /**
106
111
  * Retrieves the first schema reference and the reference chain of a given schema that
107
112
  * defines some schema properties. (e.g. schemas with just "$ref" are skipped)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/core",
3
- "version": "0.4.2",
3
+ "version": "0.5.0-beta.1",
4
4
  "description": "A tool designed to transform OpenAPI specifications into various forms with flexibility and extensibility at its core.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "tslib": "^2.6.2",
27
- "fs-extra": "^11.2.0",
27
+ "fs-extra": "^11.3.3",
28
28
  "yaml": "^2.5.1",
29
29
  "undici": "^6.0.0"
30
30
  },
package/script/mod.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './src/utils/common.utils.js';
17
17
  export * from './src/utils/endpoint.utils.js';
18
18
  export * from './src/utils/error.utils.js';
19
19
  export * from './src/utils/factory.js';
20
+ export * from './src/utils/file-system.utils.js';
20
21
  export * from './src/utils/generator.utils.js';
21
22
  export * from './src/utils/object.utils.js';
22
23
  export * from './src/utils/schema.utils.js';
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC/F,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AAErC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC/F,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
package/script/mod.js CHANGED
@@ -21,6 +21,7 @@ tslib_1.__exportStar(require("./src/utils/common.utils.js"), exports);
21
21
  tslib_1.__exportStar(require("./src/utils/endpoint.utils.js"), exports);
22
22
  tslib_1.__exportStar(require("./src/utils/error.utils.js"), exports);
23
23
  tslib_1.__exportStar(require("./src/utils/factory.js"), exports);
24
+ tslib_1.__exportStar(require("./src/utils/file-system.utils.js"), exports);
24
25
  tslib_1.__exportStar(require("./src/utils/generator.utils.js"), exports);
25
26
  tslib_1.__exportStar(require("./src/utils/object.utils.js"), exports);
26
27
  tslib_1.__exportStar(require("./src/utils/schema.utils.js"), exports);
@@ -11,6 +11,17 @@ export type OpenApiGeneratorConfig = SourceBuilderOptions & OpenApiParserOptions
11
11
  * @default true
12
12
  */
13
13
  clearOutputDir: boolean;
14
+ /**
15
+ * How to handle existing files in the output directory.
16
+ * - 'override': overwrite existing files.
17
+ * - 'skip': skip generating files that already exist.
18
+ * - 'error': throw an error if a file already exists.
19
+ *
20
+ * Is is recommended to use `'error'` to prevent issues of two schemas generating the same file and overwriting each other.
21
+ * If `clearOutputDir` is set to `false`, it is recommended to use `'override'` to ensure that the generated files are up to date.
22
+ * @default 'error'
23
+ */
24
+ existingFileBehavior: 'override' | 'skip' | 'error';
14
25
  };
15
26
  export declare const defaultOpenApiGeneratorConfig: OpenApiGeneratorConfig;
16
27
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/codegen/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,MAAM,MAAM,sBAAsB,GAC9B,oBAAoB,GACpB,oBAAoB,GACpB;IACA;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEJ,eAAO,MAAM,6BAA6B,EAAE,sBAM3C,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/codegen/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,MAAM,MAAM,sBAAsB,GAC9B,oBAAoB,GACpB,oBAAoB,GACpB;IACA;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;;;;;;OASG;IACH,oBAAoB,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;CACrD,CAAC;AAEJ,eAAO,MAAM,6BAA6B,EAAE,sBAO3C,CAAC"}
@@ -8,4 +8,5 @@ exports.defaultOpenApiGeneratorConfig = {
8
8
  ...types_js_1.defaultOpenApiTransformerOptions,
9
9
  outputDir: 'generated',
10
10
  clearOutputDir: true,
11
+ existingFileBehavior: 'error',
11
12
  };
@@ -1,3 +1,4 @@
1
+ import type { OpenApiGeneratorConfig } from '../codegen/config.js';
1
2
  import type { Nullable } from './type.utils.js';
2
3
  export type DirectoryScanOptions = {
3
4
  recursive: boolean;
@@ -6,4 +7,5 @@ export type DirectoryScanOptions = {
6
7
  };
7
8
  export declare const defaultDirectoryScanOptions: DirectoryScanOptions;
8
9
  export declare function getFiles(dir: string, options?: Partial<DirectoryScanOptions>): Promise<string[]>;
10
+ export declare function writeGeneratedFile(config: OpenApiGeneratorConfig, filePath: string, content: string): void;
9
11
  //# sourceMappingURL=file-system.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-system.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/file-system.utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,oBAGzC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKtG"}
1
+ {"version":3,"file":"file-system.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/file-system.utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,oBAGzC,CAAC;AAEF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKtG;AA0BD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAU1G"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultDirectoryScanOptions = void 0;
4
4
  exports.getFiles = getFiles;
5
+ exports.writeGeneratedFile = writeGeneratedFile;
5
6
  const tslib_1 = require("tslib");
6
7
  const node_path_1 = require("node:path");
7
8
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
@@ -34,3 +35,13 @@ async function getFilesImpl(dir, options, files, currentDepth) {
34
35
  }
35
36
  }
36
37
  }
38
+ function writeGeneratedFile(config, filePath, content) {
39
+ if (config.existingFileBehavior !== 'override' && fs_extra_1.default.existsSync(filePath)) {
40
+ if (config.existingFileBehavior === 'error') {
41
+ throw new Error(`File already exists: ${filePath}`);
42
+ }
43
+ return;
44
+ }
45
+ fs_extra_1.default.ensureDirSync((0, node_path_1.dirname)(filePath));
46
+ fs_extra_1.default.writeFileSync(filePath, content);
47
+ }
@@ -1,6 +1,7 @@
1
1
  import type { OpenApiSchema } from '../parse/openapi-types.js';
2
2
  import type { ApiSchema } from '../transform/api-types.js';
3
3
  export declare function resolveAnyOfAndAllOf(schema: ApiSchema<'combined' | 'object'>, ignoreNonObjectParts: boolean): ApiSchema<'object'> | undefined;
4
+ export declare const DEFAULT_IGNORED_SCHEMA_PROPERTIES: (keyof OpenApiSchema)[];
4
5
  /**
5
6
  * Retrieves the first schema reference and the reference chain of a given schema that
6
7
  * defines some schema properties. (e.g. schemas with just "$ref" are skipped)
@@ -1 +1 @@
1
- {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/schema.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAA0C,MAAM,2BAA2B,CAAC;AAEnG,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,UAAU,GAAG,QAAQ,CAAC,EACxC,oBAAoB,EAAE,OAAO,GAC5B,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAgCjC;AA0FD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG,SAAS,CAM5G"}
1
+ {"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/schema.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAA0C,MAAM,2BAA2B,CAAC;AAEnG,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,UAAU,GAAG,QAAQ,CAAC,EACxC,oBAAoB,EAAE,OAAO,GAC5B,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAgCjC;AA0FD,eAAO,MAAM,iCAAiC,EAAE,CAAC,MAAM,aAAa,CAAC,EAIpE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,GAAG,SAAS,CAM5G"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_IGNORED_SCHEMA_PROPERTIES = void 0;
3
4
  exports.resolveAnyOfAndAllOf = resolveAnyOfAndAllOf;
4
5
  exports.getSchemaReference = getSchemaReference;
5
6
  const internal_utils_js_1 = require("../internal-utils.js");
@@ -106,6 +107,11 @@ function hasInvalidSubSchema(subSchemas) {
106
107
  return subSchemas.some((x) => x.kind !== 'object' &&
107
108
  (x.kind !== 'combined' || (!hasInvalidSubSchema(x.allOf) && !hasInvalidSubSchema(x.anyOf))));
108
109
  }
110
+ exports.DEFAULT_IGNORED_SCHEMA_PROPERTIES = [
111
+ 'description',
112
+ 'example',
113
+ 'deprecated',
114
+ ];
109
115
  /**
110
116
  * Retrieves the first schema reference and the reference chain of a given schema that
111
117
  * defines some schema properties. (e.g. schemas with just "$ref" are skipped)
package/src/_dnt.shims.ts DELETED
@@ -1,69 +0,0 @@
1
- import { fetch, File, FormData, Headers, Request, Response } from "undici";
2
- export { fetch, File, FormData, Headers, Request, Response, type BodyInit, type HeadersInit, type ReferrerPolicy, type RequestInit, type RequestCache, type RequestMode, type RequestRedirect, type ResponseInit } from "undici";
3
-
4
- const dntGlobals = {
5
- fetch,
6
- File,
7
- FormData,
8
- Headers,
9
- Request,
10
- Response,
11
- };
12
- export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
13
-
14
- function createMergeProxy<T extends object, U extends object>(
15
- baseObj: T,
16
- extObj: U,
17
- ): Omit<T, keyof U> & U {
18
- return new Proxy(baseObj, {
19
- get(_target, prop, _receiver) {
20
- if (prop in extObj) {
21
- return (extObj as any)[prop];
22
- } else {
23
- return (baseObj as any)[prop];
24
- }
25
- },
26
- set(_target, prop, value) {
27
- if (prop in extObj) {
28
- delete (extObj as any)[prop];
29
- }
30
- (baseObj as any)[prop] = value;
31
- return true;
32
- },
33
- deleteProperty(_target, prop) {
34
- let success = false;
35
- if (prop in extObj) {
36
- delete (extObj as any)[prop];
37
- success = true;
38
- }
39
- if (prop in baseObj) {
40
- delete (baseObj as any)[prop];
41
- success = true;
42
- }
43
- return success;
44
- },
45
- ownKeys(_target) {
46
- const baseKeys = Reflect.ownKeys(baseObj);
47
- const extKeys = Reflect.ownKeys(extObj);
48
- const extKeysSet = new Set(extKeys);
49
- return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
50
- },
51
- defineProperty(_target, prop, desc) {
52
- if (prop in extObj) {
53
- delete (extObj as any)[prop];
54
- }
55
- Reflect.defineProperty(baseObj, prop, desc);
56
- return true;
57
- },
58
- getOwnPropertyDescriptor(_target, prop) {
59
- if (prop in extObj) {
60
- return Reflect.getOwnPropertyDescriptor(extObj, prop);
61
- } else {
62
- return Reflect.getOwnPropertyDescriptor(baseObj, prop);
63
- }
64
- },
65
- has(_target, prop) {
66
- return prop in extObj || prop in baseObj;
67
- },
68
- }) as any;
69
- }
package/src/mod.ts DELETED
@@ -1,33 +0,0 @@
1
- export * from './src/ast/node.js';
2
-
3
- export * from './src/codegen/config.js';
4
- export * from './src/codegen/endpoints-generator.js';
5
- export * from './src/codegen/generator.js';
6
- export * from './src/codegen/schemas-generator.js';
7
- export * from './src/codegen/services-generator.js';
8
- export * from './src/codegen/types.js';
9
-
10
- export * from './src/parse/openapi-types.js';
11
- export * from './src/parse/parser.js';
12
- export * from './src/parse/types.js';
13
-
14
- export * from './src/transform/api-types.js';
15
- export * from './src/transform/transformer.js';
16
-
17
- export * from './src/utils/array.utils.js';
18
- export * from './src/utils/asset-manager.js';
19
- export * from './src/utils/class.utils.js';
20
- export * from './src/utils/common.utils.js';
21
- export * from './src/utils/endpoint.utils.js';
22
- export * from './src/utils/error.utils.js';
23
- export * from './src/utils/factory.js';
24
- export * from './src/utils/generator.utils.js';
25
- export * from './src/utils/object.utils.js';
26
- export * from './src/utils/schema.utils.js';
27
- export * from './src/utils/source-builder.js';
28
- export * from './src/utils/string-builder/options.js';
29
- export { type AppendParam, StringBuilder } from './src/utils/string-builder/string-builder.js';
30
- export * from './src/utils/string-builder/utils.js';
31
- export * from './src/utils/string.utils.js';
32
- export * from './src/utils/string.utils.types.js';
33
- export * from './src/utils/type.utils.js';
@@ -1,46 +0,0 @@
1
- import type { StringBuilder } from '../utils/string-builder/string-builder.js';
2
- import type { AppendValue } from '../utils/string-builder/utils.js';
3
- import type { Prettify } from '../utils/type.utils.js';
4
-
5
- const NODE_HISTORY_SYMBOL = Symbol('node-history');
6
- type BuilderWithHistory<T extends StringBuilder = StringBuilder> = T & { [NODE_HISTORY_SYMBOL]?: AstNode[] };
7
-
8
- export type AstNodeInject<TBuilder extends StringBuilder, TInjects extends string> = {
9
- [K in `${'after' | 'before'}${Capitalize<TInjects>}`]?: AppendValue<TBuilder>;
10
- };
11
-
12
- export type AstNodeOptions<
13
- // deno-lint-ignore no-explicit-any
14
- TBase extends abstract new (...args: any) => any,
15
- // deno-lint-ignore ban-types
16
- TExtensions extends object = {},
17
- > = Prettify<TExtensions & ConstructorParameters<TBase>[0]>;
18
-
19
- export abstract class AstNode<TBuilder extends StringBuilder = StringBuilder, TInjects extends string = never> {
20
- public inject: AstNodeInject<TBuilder, TInjects | ''>;
21
-
22
- constructor(options: { inject?: AstNode<TBuilder, TInjects>['inject'] }) {
23
- this.inject = options.inject ?? {};
24
- }
25
-
26
- public write(builder: TBuilder): void {
27
- let history = (builder as BuilderWithHistory)[NODE_HISTORY_SYMBOL];
28
- if (!history) {
29
- history = [];
30
- (builder as BuilderWithHistory)[NODE_HISTORY_SYMBOL] = history;
31
- }
32
-
33
- history.push(this);
34
- builder.append(this.inject.before);
35
- this.onWrite(builder);
36
- builder.append(this.inject.after);
37
- history.pop();
38
- }
39
-
40
- protected getParentNode(builder: TBuilder): AstNode | undefined {
41
- const history = (builder as BuilderWithHistory)[NODE_HISTORY_SYMBOL];
42
- return history?.at(-2);
43
- }
44
-
45
- protected abstract onWrite(builder: TBuilder): void;
46
- }
@@ -1,28 +0,0 @@
1
- import type { OpenApiParserOptions } from '../parse/types.js';
2
- import { defaultOpenApiTransformerOptions } from '../transform/types.js';
3
- import { defaultSourceBuilderOptions, type SourceBuilderOptions } from '../utils/source-builder.js';
4
-
5
- export type OpenApiGeneratorConfig =
6
- & SourceBuilderOptions
7
- & OpenApiParserOptions
8
- & {
9
- /**
10
- * The directory where the generated files should be saved.
11
- * @default 'generated'
12
- */
13
- outputDir: string;
14
-
15
- /**
16
- * Whether to clear the output directory before generating the files.
17
- * @default true
18
- */
19
- clearOutputDir: boolean;
20
- };
21
-
22
- export const defaultOpenApiGeneratorConfig: OpenApiGeneratorConfig = {
23
- ...defaultSourceBuilderOptions,
24
- ...defaultOpenApiTransformerOptions,
25
-
26
- outputDir: 'generated',
27
- clearOutputDir: true,
28
- };
@@ -1,72 +0,0 @@
1
- import type { ApiEndpoint } from '../transform/api-types.js';
2
- import type { MaybePromise } from '../utils/type.utils.js';
3
- import { type DefaultGenerationProviderConfig, OpenApiGenerationProviderBase } from './generator.js';
4
- import { addSourceIfTest } from './internal-utils.js';
5
- import type {
6
- AnyConfig,
7
- OpenApiGenerationProviderContext,
8
- OpenApiGeneratorContext,
9
- OpenApiGeneratorInput,
10
- OpenApiGeneratorOutput,
11
- } from './types.js';
12
-
13
- export type OpenApiEndpointsGenerationProviderContext<
14
- TInput extends OpenApiGeneratorInput,
15
- TOutput extends OpenApiGeneratorOutput,
16
- TConfig extends AnyConfig,
17
- TEndpointOutput extends OpenApiGeneratorOutput,
18
- > = OpenApiGenerationProviderContext<TInput, TConfig> & {
19
- existingEndpointResults: Map<string, TEndpointOutput>;
20
- output: TOutput;
21
- };
22
-
23
- export abstract class OpenApiEndpointsGenerationProviderBase<
24
- TInput extends OpenApiGeneratorInput,
25
- TOutput extends OpenApiGeneratorOutput,
26
- TConfig extends AnyConfig,
27
- TEndpointOutput extends OpenApiGeneratorOutput,
28
- TContext extends OpenApiEndpointsGenerationProviderContext<TInput, TOutput, TConfig, TEndpointOutput>,
29
- > extends OpenApiGenerationProviderBase<TInput, TOutput, TConfig, TContext> {
30
- protected override getProviderContext(
31
- context: OpenApiGeneratorContext<TInput>,
32
- config: Partial<TConfig> | undefined,
33
- defaultConfig: DefaultGenerationProviderConfig<TConfig>,
34
- ): OpenApiEndpointsGenerationProviderContext<TInput, TOutput, TConfig, TEndpointOutput> {
35
- const ctx = super.getProviderContext(context, config, defaultConfig);
36
- return Object.assign(ctx, {
37
- existingEndpointResults: new Map<string, TEndpointOutput>(),
38
- output: this.initResult(ctx),
39
- });
40
- }
41
-
42
- protected override async onGenerate(ctx: TContext): Promise<TOutput> {
43
- for (const endpoint of ctx.data.endpoints) {
44
- await this.getEndpointResult(ctx, endpoint);
45
- }
46
-
47
- await this.generateAdditionalFiles(ctx);
48
-
49
- return ctx.output;
50
- }
51
-
52
- public async getEndpointResult(ctx: TContext, endpoint: ApiEndpoint): Promise<TEndpointOutput> {
53
- const existingResult = ctx.existingEndpointResults.get(endpoint.id);
54
- if (existingResult) return existingResult;
55
-
56
- const result = await this.generateEndpoint(ctx, endpoint);
57
- addSourceIfTest(ctx.config, result, () => `${endpoint.$src.file}#${endpoint.$src.path}`);
58
- this.addEndpointResult(ctx, endpoint, result);
59
- return result;
60
- }
61
-
62
- protected abstract initResult(ctx: OpenApiGenerationProviderContext<TInput, TConfig>): TOutput;
63
-
64
- protected abstract generateEndpoint(ctx: TContext, endpoint: ApiEndpoint): Promise<TEndpointOutput>;
65
-
66
- protected abstract addEndpointResult(ctx: TContext, endpoint: ApiEndpoint, result: TEndpointOutput): void;
67
-
68
- // deno-lint-ignore no-unused-vars
69
- protected generateAdditionalFiles(ctx: TContext): MaybePromise<void> {
70
- // Override if needed
71
- }
72
- }