@trapi/swagger 1.0.0-alpha.2 → 1.0.0-alpha.3

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 (144) hide show
  1. package/dist/config/index.d.ts +3 -0
  2. package/dist/config/index.d.ts.map +1 -0
  3. package/dist/config/index.js +25 -0
  4. package/dist/config/index.js.map +1 -0
  5. package/dist/config/type.d.ts +83 -0
  6. package/dist/config/type.d.ts.map +1 -0
  7. package/dist/config/type.js +9 -0
  8. package/dist/config/type.js.map +1 -0
  9. package/dist/config/utils.d.ts +3 -0
  10. package/dist/config/utils.d.ts.map +1 -0
  11. package/dist/config/utils.js +52 -0
  12. package/dist/config/utils.js.map +1 -0
  13. package/dist/constants.d.ts +15 -0
  14. package/dist/constants.d.ts.map +1 -0
  15. package/dist/constants.js +27 -0
  16. package/dist/constants.js.map +1 -0
  17. package/dist/generator/abstract.d.ts +27 -0
  18. package/dist/generator/abstract.d.ts.map +1 -0
  19. package/dist/{specification → generator}/abstract.js +39 -29
  20. package/dist/generator/abstract.js.map +1 -0
  21. package/dist/{specification → generator}/index.d.ts +0 -2
  22. package/dist/generator/index.d.ts.map +1 -0
  23. package/dist/{specification → generator}/index.js +1 -3
  24. package/dist/generator/index.js.map +1 -0
  25. package/dist/generator/module.d.ts +14 -0
  26. package/dist/generator/module.d.ts.map +1 -0
  27. package/dist/generator/module.js +35 -0
  28. package/dist/generator/module.js.map +1 -0
  29. package/dist/generator/v2/index.d.ts +2 -0
  30. package/dist/generator/v2/index.d.ts.map +1 -0
  31. package/dist/{specification/utils → generator/v2}/index.js +2 -2
  32. package/dist/generator/v2/index.js.map +1 -0
  33. package/dist/generator/v2/module.d.ts +25 -0
  34. package/dist/generator/v2/module.d.ts.map +1 -0
  35. package/dist/generator/v2/module.js +501 -0
  36. package/dist/generator/v2/module.js.map +1 -0
  37. package/dist/generator/v3/index.d.ts +2 -0
  38. package/dist/generator/v3/index.d.ts.map +1 -0
  39. package/dist/generator/v3/index.js +24 -0
  40. package/dist/generator/v3/index.js.map +1 -0
  41. package/dist/generator/v3/module.d.ts +27 -0
  42. package/dist/generator/v3/module.d.ts.map +1 -0
  43. package/dist/{specification → generator}/v3/module.js +170 -109
  44. package/dist/generator/v3/module.js.map +1 -0
  45. package/dist/index.d.ts +3 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +3 -2
  48. package/dist/index.js.map +1 -1
  49. package/dist/schema/constants.d.ts +7 -0
  50. package/dist/schema/constants.d.ts.map +1 -0
  51. package/dist/schema/constants.js +17 -0
  52. package/dist/schema/constants.js.map +1 -0
  53. package/dist/schema/index.d.ts +5 -0
  54. package/dist/schema/index.d.ts.map +1 -0
  55. package/dist/schema/index.js +27 -0
  56. package/dist/schema/index.js.map +1 -0
  57. package/dist/schema/type.d.ts +140 -0
  58. package/dist/schema/type.d.ts.map +1 -0
  59. package/dist/schema/type.js.map +1 -0
  60. package/dist/schema/v2/constants.d.ts +8 -0
  61. package/dist/schema/v2/constants.d.ts.map +1 -0
  62. package/dist/schema/v2/constants.js +18 -0
  63. package/dist/schema/v2/constants.js.map +1 -0
  64. package/dist/schema/v2/index.d.ts +3 -0
  65. package/dist/schema/v2/index.d.ts.map +1 -0
  66. package/dist/{specification/v3 → schema/v2}/index.js +1 -1
  67. package/dist/schema/v2/index.js.map +1 -0
  68. package/dist/schema/v2/type.d.ts +116 -0
  69. package/dist/schema/v2/type.d.ts.map +1 -0
  70. package/dist/schema/v2/type.js.map +1 -0
  71. package/dist/schema/v3/constants.d.ts +7 -0
  72. package/dist/schema/v3/constants.d.ts.map +1 -0
  73. package/dist/schema/v3/constants.js +17 -0
  74. package/dist/schema/v3/constants.js.map +1 -0
  75. package/dist/schema/v3/index.d.ts +3 -0
  76. package/dist/schema/v3/index.d.ts.map +1 -0
  77. package/dist/{specification/v2 → schema/v3}/index.js +1 -1
  78. package/dist/schema/v3/index.js.map +1 -0
  79. package/dist/schema/v3/type.d.ts +158 -0
  80. package/dist/schema/v3/type.d.ts.map +1 -0
  81. package/dist/schema/v3/type.js +9 -0
  82. package/dist/schema/v3/type.js.map +1 -0
  83. package/dist/type.d.ts +44 -2
  84. package/dist/type.d.ts.map +1 -1
  85. package/dist/utils/character.d.ts +3 -0
  86. package/dist/utils/character.d.ts.map +1 -0
  87. package/dist/{specification/utils → utils}/character.js +3 -4
  88. package/dist/utils/character.js.map +1 -0
  89. package/dist/utils/index.d.ts +2 -0
  90. package/dist/utils/index.d.ts.map +1 -1
  91. package/dist/utils/index.js +2 -0
  92. package/dist/utils/index.js.map +1 -1
  93. package/dist/utils/object.d.ts.map +1 -1
  94. package/dist/utils/object.js +1 -0
  95. package/dist/utils/object.js.map +1 -1
  96. package/dist/utils/value.d.ts +2 -0
  97. package/dist/utils/value.d.ts.map +1 -0
  98. package/dist/utils/value.js +26 -0
  99. package/dist/utils/value.js.map +1 -0
  100. package/package.json +5 -4
  101. package/dist/module.d.ts +0 -8
  102. package/dist/module.d.ts.map +0 -1
  103. package/dist/module.js +0 -19
  104. package/dist/module.js.map +0 -1
  105. package/dist/specification/abstract.d.ts +0 -28
  106. package/dist/specification/abstract.d.ts.map +0 -1
  107. package/dist/specification/abstract.js.map +0 -1
  108. package/dist/specification/index.d.ts.map +0 -1
  109. package/dist/specification/index.js.map +0 -1
  110. package/dist/specification/module.d.ts +0 -6
  111. package/dist/specification/module.d.ts.map +0 -1
  112. package/dist/specification/module.js +0 -29
  113. package/dist/specification/module.js.map +0 -1
  114. package/dist/specification/type.d.ts +0 -268
  115. package/dist/specification/type.d.ts.map +0 -1
  116. package/dist/specification/type.js +0 -18
  117. package/dist/specification/type.js.map +0 -1
  118. package/dist/specification/utils/character.d.ts +0 -3
  119. package/dist/specification/utils/character.d.ts.map +0 -1
  120. package/dist/specification/utils/character.js.map +0 -1
  121. package/dist/specification/utils/index.d.ts +0 -2
  122. package/dist/specification/utils/index.d.ts.map +0 -1
  123. package/dist/specification/utils/index.js.map +0 -1
  124. package/dist/specification/v2/index.d.ts +0 -3
  125. package/dist/specification/v2/index.d.ts.map +0 -1
  126. package/dist/specification/v2/index.js.map +0 -1
  127. package/dist/specification/v2/module.d.ts +0 -24
  128. package/dist/specification/v2/module.d.ts.map +0 -1
  129. package/dist/specification/v2/module.js +0 -405
  130. package/dist/specification/v2/module.js.map +0 -1
  131. package/dist/specification/v2/type.d.ts +0 -79
  132. package/dist/specification/v2/type.d.ts.map +0 -1
  133. package/dist/specification/v2/type.js.map +0 -1
  134. package/dist/specification/v3/index.d.ts +0 -3
  135. package/dist/specification/v3/index.d.ts.map +0 -1
  136. package/dist/specification/v3/index.js.map +0 -1
  137. package/dist/specification/v3/module.d.ts +0 -24
  138. package/dist/specification/v3/module.d.ts.map +0 -1
  139. package/dist/specification/v3/module.js.map +0 -1
  140. package/dist/specification/v3/type.d.ts +0 -121
  141. package/dist/specification/v3/type.d.ts.map +0 -1
  142. package/dist/specification/v3/type.js.map +0 -1
  143. /package/dist/{specification/v2 → schema}/type.js +0 -0
  144. /package/dist/{specification/v3 → schema/v2}/type.js +0 -0
@@ -0,0 +1,3 @@
1
+ export * from './type';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023.
4
+ * Author Peter Placzek (tada5hi)
5
+ * For the full copyright and license information,
6
+ * view the LICENSE file that was distributed with this source code.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./type"), exports);
24
+ __exportStar(require("./utils"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB;AACvB,0CAAwB"}
@@ -0,0 +1,83 @@
1
+ import type { CollectionFormat, Metadata, Options as MetadataOptions } from '@trapi/metadata';
2
+ import type { SecurityDefinitions } from '../type';
3
+ export type ServerOption = {
4
+ url: string;
5
+ description?: string;
6
+ };
7
+ export interface Options {
8
+ /**
9
+ * Generate a yaml file
10
+ */
11
+ yaml?: boolean;
12
+ /**
13
+ * Specify if an output file should be generated.
14
+ *
15
+ * default: true
16
+ */
17
+ output: boolean;
18
+ /**
19
+ * Generated swagger.{json|yaml} will output here.
20
+ *
21
+ * default: process.cwd()
22
+ */
23
+ outputDirectory: string;
24
+ /**
25
+ * Generated documentation base file name.
26
+ *
27
+ * default: swagger
28
+ */
29
+ outputFileName: string;
30
+ /**
31
+ * API host, expressTemplate.g. localhost:3000 or https://myapi.com
32
+ */
33
+ servers?: ServerOption[];
34
+ /**
35
+ * Metadata options or metadata itself.
36
+ */
37
+ metadata?: MetadataOptions | Metadata;
38
+ /**
39
+ * API version number; defaults to npm package version
40
+ */
41
+ version?: string;
42
+ /**
43
+ * API name; defaults to npm package name
44
+ */
45
+ name?: string;
46
+ /**
47
+ * 'API description; defaults to npm package description
48
+ */
49
+ description?: string;
50
+ /**
51
+ * API license; defaults to npm package license
52
+ */
53
+ license?: string;
54
+ /**
55
+ * Extend generated swagger spec with this object
56
+ * Note that generated properties will always take precedence over what get specified here
57
+ */
58
+ specificationExtra?: Record<string, any>;
59
+ /**
60
+ * Security Definitions Object
61
+ * A declaration of the security schemes available to be used in the
62
+ * specification. This does not enforce the security schemes on the operations
63
+ * and only serves to provide the relevant details for each scheme.
64
+ */
65
+ securityDefinitions?: SecurityDefinitions;
66
+ /**
67
+ * Default consumes property for the entire API
68
+ */
69
+ consumes?: string[];
70
+ /**
71
+ * Default produces property for the entire API
72
+ */
73
+ produces?: string[];
74
+ /**
75
+ * Default collectionFormat property for query parameters of array type.
76
+ * Possible values are `csv`, `ssv`, `tsv`, `pipes`, `multi`. If not specified, Swagger defaults to `csv`.
77
+ */
78
+ collectionFormat?: `${CollectionFormat}`;
79
+ }
80
+ export type OptionsInput = Omit<Partial<Options>, 'servers'> & {
81
+ servers?: string | string[] | ServerOption | ServerOption[];
82
+ };
83
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;IAEtC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEzC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,GAAG,gBAAgB,EAAE,CAAC;CAC5C;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,GAAG;IAC3D,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,GAAG,YAAY,EAAE,CAAA;CAC9D,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023.
4
+ * Author Peter Placzek (tada5hi)
5
+ * For the full copyright and license information,
6
+ * view the LICENSE file that was distributed with this source code.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/config/type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,3 @@
1
+ import type { Options, OptionsInput } from './type';
2
+ export declare function buildOptions(input: OptionsInput): Options;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/config/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAgB,MAAM,QAAQ,CAAC;AAElE,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAI,OAAO,CAiC1D"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023.
4
+ * Author Peter Placzek (tada5hi)
5
+ * For the full copyright and license information,
6
+ * view the LICENSE file that was distributed with this source code.
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.buildOptions = void 0;
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ const node_process_1 = __importDefault(require("node:process"));
15
+ function buildOptions(input) {
16
+ const servers = [];
17
+ if (Array.isArray(input.servers)) {
18
+ for (let i = 0; i < input.servers.length; i++) {
19
+ const server = input.servers[i];
20
+ if (typeof server === 'string') {
21
+ servers.push({ url: server });
22
+ }
23
+ else {
24
+ servers.push(server);
25
+ }
26
+ }
27
+ }
28
+ else if (typeof input.servers === 'string') {
29
+ servers.push({ url: input.servers });
30
+ }
31
+ else {
32
+ servers.push(input.servers);
33
+ }
34
+ let outputDirectory;
35
+ if (input.outputDirectory) {
36
+ outputDirectory = node_path_1.default.isAbsolute(input.outputDirectory) ?
37
+ input.outputDirectory :
38
+ node_path_1.default.join(node_process_1.default.cwd(), input.outputDirectory);
39
+ }
40
+ else {
41
+ outputDirectory = node_process_1.default.cwd();
42
+ }
43
+ return {
44
+ ...input,
45
+ output: input.output ?? true,
46
+ outputDirectory,
47
+ outputFileName: input.outputFileName || 'swagger',
48
+ servers,
49
+ };
50
+ }
51
+ exports.buildOptions = buildOptions;
52
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/config/utils.ts"],"names":[],"mappings":";AAAA;;;;;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IAAI,SAAS;QACjD,OAAO;KACV,CAAC;AACN,CAAC;AAjCD,oCAiCC"}
@@ -0,0 +1,15 @@
1
+ export declare enum Version {
2
+ V2 = "V2",
3
+ V3 = "V3"
4
+ }
5
+ export declare enum DocumentFormat {
6
+ YAML = "yaml",
7
+ JSON = "json"
8
+ }
9
+ export declare enum SecurityType {
10
+ API_KEY = "apiKey",
11
+ BASIC = "basic",
12
+ HTTP = "http",
13
+ OAUTH2 = "oauth2"
14
+ }
15
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,OAAO;IACf,EAAE,OAAO;IACT,EAAE,OAAO;CACZ;AAED,oBAAY,cAAc;IACtB,IAAI,SAAS;IACb,IAAI,SAAS;CAChB;AAED,oBAAY,YAAY;IACpB,OAAO,WAAW;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;CACpB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023.
4
+ * Author Peter Placzek (tada5hi)
5
+ * For the full copyright and license information,
6
+ * view the LICENSE file that was distributed with this source code.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SecurityType = exports.DocumentFormat = exports.Version = void 0;
10
+ var Version;
11
+ (function (Version) {
12
+ Version["V2"] = "V2";
13
+ Version["V3"] = "V3";
14
+ })(Version = exports.Version || (exports.Version = {}));
15
+ var DocumentFormat;
16
+ (function (DocumentFormat) {
17
+ DocumentFormat["YAML"] = "yaml";
18
+ DocumentFormat["JSON"] = "json";
19
+ })(DocumentFormat = exports.DocumentFormat || (exports.DocumentFormat = {}));
20
+ var SecurityType;
21
+ (function (SecurityType) {
22
+ SecurityType["API_KEY"] = "apiKey";
23
+ SecurityType["BASIC"] = "basic";
24
+ SecurityType["HTTP"] = "http";
25
+ SecurityType["OAUTH2"] = "oauth2";
26
+ })(SecurityType = exports.SecurityType || (exports.SecurityType = {}));
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,oBAAS,CAAA;IACT,oBAAS,CAAA;AACb,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,+BAAa,CAAA;IACb,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,kCAAkB,CAAA;IAClB,+BAAe,CAAA;IACf,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACrB,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB"}
@@ -0,0 +1,27 @@
1
+ import type { BaseType, EnumType, IntersectionType, Metadata, NestedObjectLiteralType, Parameter, ParameterSource, ReferenceType, ResolverProperty, UnionType } from '@trapi/metadata';
2
+ import type { Options, OptionsInput } from '../config';
3
+ import type { DocumentFormat } from '../constants';
4
+ import type { DocumentFormatData } from '../type';
5
+ import type { BaseSchema, Info, SchemaV2, SchemaV3, SpecV2, SpecV3 } from '../schema';
6
+ export declare abstract class AbstractSpecGenerator<Spec extends SpecV2 | SpecV3, Schema extends SchemaV3 | SchemaV2> {
7
+ protected spec: Spec | undefined;
8
+ protected readonly metadata: Metadata;
9
+ protected readonly config: Options;
10
+ constructor(metadata: Metadata, config: OptionsInput);
11
+ save(): Promise<Record<`${DocumentFormat}`, DocumentFormatData>>;
12
+ abstract build(): Promise<Spec>;
13
+ protected buildInfo(): Info;
14
+ protected getSwaggerType(type: BaseType): Schema | BaseSchema<Schema>;
15
+ protected abstract getSwaggerTypeForIntersectionType(type: IntersectionType): Schema;
16
+ protected abstract getSwaggerTypeForEnumType(enumType: EnumType): Schema;
17
+ protected getSwaggerTypeForUnionType(type: UnionType): Schema | BaseSchema<Schema>;
18
+ private getSwaggerTypeForPrimitiveType;
19
+ private getSwaggerTypeForArrayType;
20
+ getSwaggerTypeForObjectLiteral(objectLiteral: NestedObjectLiteralType): BaseSchema<Schema>;
21
+ protected abstract getSwaggerTypeForReferenceType(referenceType: ReferenceType): Schema;
22
+ protected abstract buildProperties(properties: ResolverProperty[]): Record<string, Schema>;
23
+ protected determineTypesUsedInEnum(anEnum: Array<string | number | boolean | null>): Set<"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function">;
24
+ protected getOperationId(methodName: string): string;
25
+ protected groupParameters(items: Parameter[]): Partial<Record<ParameterSource, Parameter[]>>;
26
+ }
27
+ //# sourceMappingURL=abstract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAER,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,uBAAuB,EACvB,SAAS,EACT,eAAe,EAEf,aAAa,EACb,gBAAgB,EAEhB,SAAS,EACZ,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EACR,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACT,MAAM,WAAW,CAAC;AAEnB,8BAAsB,qBAAqB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,SAAS,QAAQ,GAAG,QAAQ;IACxG,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAEjC,SAAS,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SAAS,EAAE,CAAC,CAAC;CAahG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2021.
3
+ * Copyright (c) 2021-2023.
4
4
  * Author Peter Placzek (tada5hi)
5
5
  * For the full copyright and license information,
6
6
  * view the LICENSE file that was distributed with this source code.
@@ -14,45 +14,45 @@ const metadata_1 = require("@trapi/metadata");
14
14
  const node_path_1 = __importDefault(require("node:path"));
15
15
  const node_fs_1 = __importDefault(require("node:fs"));
16
16
  const yamljs_1 = __importDefault(require("yamljs"));
17
+ const config_1 = require("../config");
17
18
  const utils_1 = require("../utils");
18
19
  class AbstractSpecGenerator {
19
20
  constructor(metadata, config) {
20
21
  this.metadata = metadata;
21
- this.config = config;
22
+ this.config = (0, config_1.buildOptions)(config);
22
23
  }
23
24
  async save() {
24
- const spec = this.build();
25
- const swaggerDir = node_path_1.default.resolve(this.config.outputDirectory);
26
- await node_fs_1.default.promises.mkdir(swaggerDir, { recursive: true });
27
- const data = {
28
- json: {
29
- path: node_path_1.default.join(swaggerDir, 'swagger.json'),
25
+ if (!this.config.output) {
26
+ return;
27
+ }
28
+ if (typeof this.spec === 'undefined') {
29
+ throw new Error('The spec has not been build yet...');
30
+ }
31
+ try {
32
+ await node_fs_1.default.promises.access(this.config.outputDirectory, node_fs_1.default.constants.R_OK | node_fs_1.default.constants.O_DIRECTORY);
33
+ }
34
+ catch (e) {
35
+ await node_fs_1.default.promises.mkdir(this.config.outputDirectory, { recursive: true });
36
+ }
37
+ const data = [
38
+ {
39
+ path: node_path_1.default.join(this.config.outputDirectory, `${this.config.outputFileName}.json`),
30
40
  name: 'swagger.json',
31
- content: JSON.stringify(spec, null, '\t'),
41
+ content: JSON.stringify(this.spec, null, 4),
32
42
  },
33
- yaml: undefined,
34
- };
43
+ ];
35
44
  if (this.config.yaml) {
36
- data.yaml = {
37
- path: node_path_1.default.join(swaggerDir, 'swagger.yaml'),
45
+ data.push({
46
+ path: node_path_1.default.join(this.config.outputDirectory, `${this.config.outputDirectory}.yaml`),
38
47
  name: 'swagger.yaml',
39
- content: yamljs_1.default.stringify(spec, 1000),
40
- };
41
- }
42
- const filePromises = [];
43
- const keys = Object.keys(data);
44
- for (let i = 0; i < keys.length; i++) {
45
- if (typeof data[keys[i]] === 'undefined') {
46
- continue;
47
- }
48
- const output = data[keys[i]];
49
- filePromises.push(node_fs_1.default.promises.writeFile(output.path, output.content));
48
+ content: yamljs_1.default.stringify(this.spec, 1000),
49
+ });
50
50
  }
51
- await Promise.all(filePromises);
52
- return data;
53
- }
54
- getMetaData() {
55
- return this.metadata;
51
+ const promises = [];
52
+ for (let i = 0; i < data.length; i++) {
53
+ promises.push(node_fs_1.default.promises.writeFile(data[i].path, data[i].content, { encoding: 'utf-8' }));
54
+ }
55
+ await Promise.all(promises);
56
56
  }
57
57
  buildInfo() {
58
58
  const info = {
@@ -195,6 +195,16 @@ class AbstractSpecGenerator {
195
195
  getOperationId(methodName) {
196
196
  return methodName.charAt(0).toUpperCase() + methodName.substring(1);
197
197
  }
198
+ groupParameters(items) {
199
+ const output = {};
200
+ for (let i = 0; i < items.length; i++) {
201
+ if (typeof output[items[i].in] === 'undefined') {
202
+ output[items[i].in] = [];
203
+ }
204
+ output[items[i].in].push(items[i]);
205
+ }
206
+ return output;
207
+ }
198
208
  }
199
209
  exports.AbstractSpecGenerator = AbstractSpecGenerator;
200
210
  //# sourceMappingURL=abstract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../src/generator/abstract.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAiBH,8CAUyB;AAEzB,0DAA6B;AAC7B,sDAAyB;AACzB,oDAA0B;AAC1B,sCAAyC;AAGzC,oCAA0C;AAY1C,MAAsB,qBAAqB;IAOvC,YAAY,QAAkB,EAAE,MAAoB;QAChD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAA,qBAAY,EAAC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AE,CAAC,GAAG,EAAE,CAAC;aAC5B;YAED,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACtC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA1OD,sDA0OC"}
@@ -2,6 +2,4 @@ export * from './v2';
2
2
  export * from './v3';
3
3
  export * from './abstract';
4
4
  export * from './module';
5
- export * from './type';
6
- export * from './utils';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAOA,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2021.
3
+ * Copyright (c) 2023.
4
4
  * Author Peter Placzek (tada5hi)
5
5
  * For the full copyright and license information,
6
6
  * view the LICENSE file that was distributed with this source code.
@@ -24,6 +24,4 @@ __exportStar(require("./v2"), exports);
24
24
  __exportStar(require("./v3"), exports);
25
25
  __exportStar(require("./abstract"), exports);
26
26
  __exportStar(require("./module"), exports);
27
- __exportStar(require("./type"), exports);
28
- __exportStar(require("./utils"), exports);
29
27
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,uCAAqB;AACrB,uCAAqB;AACrB,6CAA2B;AAC3B,2CAAyB"}
@@ -0,0 +1,14 @@
1
+ import type { CompilerOptions } from '@trapi/metadata';
2
+ import type { OptionsInput } from '../config';
3
+ import { Version } from '../constants';
4
+ import type { SpecV2, SpecV3 } from '../schema';
5
+ export declare function buildMetadata(options: OptionsInput, tsConfig?: CompilerOptions): Promise<import("@trapi/metadata").Metadata>;
6
+ export type DocumentationGenerationContext<V extends `${Version}`> = {
7
+ version: V;
8
+ options: OptionsInput;
9
+ tsConfig?: CompilerOptions;
10
+ };
11
+ type OutputSpec<V extends `${Version}`> = V extends `${Version.V2}` ? SpecV2 : SpecV3;
12
+ export declare function generate<V extends `${Version}`>(context: DocumentationGenerationContext<V>): Promise<OutputSpec<V>>;
13
+ export {};
14
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/generator/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIhD,wBAAsB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,eAAe,+CAMpF;AAED,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,GAAG,OAAO,EAAE,IAAI;IACjE,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC7B,CAAC;AAEF,KAAK,UAAU,CAAC,CAAC,SAAS,GAAG,OAAO,EAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE,EAAE,GAC/D,MAAM,GACN,MAAM,CAAC;AAEX,wBAAsB,QAAQ,CAAC,CAAC,SAAS,GAAG,OAAO,EAAE,EACjD,OAAO,EAAE,8BAA8B,CAAC,CAAC,CAAC,GAC3C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAexB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021-2023.
4
+ * Author Peter Placzek (tada5hi)
5
+ * For the full copyright and license information,
6
+ * view the LICENSE file that was distributed with this source code.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.generate = exports.buildMetadata = void 0;
10
+ const metadata_1 = require("@trapi/metadata");
11
+ const constants_1 = require("../constants");
12
+ const v2_1 = require("./v2");
13
+ const v3_1 = require("./v3");
14
+ async function buildMetadata(options, tsConfig) {
15
+ if ((0, metadata_1.isMetadata)(options.metadata)) {
16
+ return options.metadata;
17
+ }
18
+ return (0, metadata_1.generateMetadata)(options.metadata, tsConfig);
19
+ }
20
+ exports.buildMetadata = buildMetadata;
21
+ async function generate(context) {
22
+ const metadata = await buildMetadata(context.options);
23
+ switch (context.version) {
24
+ case constants_1.Version.V3: {
25
+ const generator = new v3_1.V3Generator(metadata, context.options);
26
+ return await generator.build();
27
+ }
28
+ default: {
29
+ const generator = new v2_1.V2Generator(metadata, context.options);
30
+ return await generator.build();
31
+ }
32
+ }
33
+ }
34
+ exports.generate = generate;
35
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/generator/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,8CAA+D;AAE/D,4CAAuC;AAEvC,6BAAmC;AACnC,6BAAmC;AAE5B,KAAK,UAAU,aAAa,CAAC,OAAqB,EAAE,QAA0B;IACjF,IAAI,IAAA,qBAAU,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC;KAC3B;IAED,OAAO,IAAA,2BAAgB,EAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAND,sCAMC;AAYM,KAAK,UAAU,QAAQ,CAC1B,OAA0C;IAE1C,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtD,QAAQ,OAAO,CAAC,OAAO,EAAE;QACrB,KAAK,mBAAO,CAAC,EAAE,CAAC,CAAC;YACb,MAAM,SAAS,GAAG,IAAI,gBAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAE7D,OAAO,MAAM,SAAS,CAAC,KAAK,EAAmB,CAAC;SACnD;QACD,OAAO,CAAC,CAAC;YACL,MAAM,SAAS,GAAG,IAAI,gBAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAE7D,OAAO,MAAM,SAAS,CAAC,KAAK,EAAmB,CAAC;SACnD;KACJ;AACL,CAAC;AAjBD,4BAiBC"}
@@ -0,0 +1,2 @@
1
+ export * from './module';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/v2/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2022-2022.
3
+ * Copyright (c) 2023.
4
4
  * Author Peter Placzek (tada5hi)
5
5
  * For the full copyright and license information,
6
6
  * view the LICENSE file that was distributed with this source code.
@@ -20,5 +20,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./character"), exports);
23
+ __exportStar(require("./module"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/v2/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB"}
@@ -0,0 +1,25 @@
1
+ import type { EnumType, IntersectionType, Parameter, ReferenceType, ResolverProperty } from '@trapi/metadata';
2
+ import { AbstractSpecGenerator } from '../abstract';
3
+ import type { ParameterV2, SchemaV2, SpecV2 } from '../../schema';
4
+ export declare class V2Generator extends AbstractSpecGenerator<SpecV2, SchemaV2> {
5
+ build(): Promise<SpecV2>;
6
+ private static translateSecurityDefinitions;
7
+ private buildDefinition;
8
+ private buildDefinitions;
9
+ private decideEnumType;
10
+ private buildPaths;
11
+ private buildMethod;
12
+ private transformParameterSource;
13
+ protected buildParameter(input: Parameter): ParameterV2;
14
+ private buildMethodConsumes;
15
+ private hasFileParams;
16
+ private hasFormParams;
17
+ private supportsBodyParameters;
18
+ protected getSwaggerTypeForEnumType(enumType: EnumType): SchemaV2;
19
+ protected getSwaggerTypeForIntersectionType(type: IntersectionType): SchemaV2;
20
+ protected getSwaggerTypeForReferenceType(referenceType: ReferenceType): SchemaV2;
21
+ protected buildProperties(properties: ResolverProperty[]): Record<string, SchemaV2>;
22
+ private buildOperation;
23
+ private getMimeType;
24
+ }
25
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/generator/v2/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,QAAQ,EACR,gBAAgB,EAEhB,SAAS,EAET,aAAa,EACb,gBAAgB,EAEnB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAKR,WAAW,EAGX,QAAQ,EAER,MAAM,EACT,MAAM,cAAc,CAAC;AAGtB,qBAAa,WAAY,SAAQ,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC9D,KAAK,IAAK,OAAO,CAAC,MAAM,CAAC;IA+C/B,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAmE3C,OAAO,CAAC,eAAe;IAyDvB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,WAAW;IAwGnB,OAAO,CAAC,wBAAwB;IA4BhC,S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