nestjs-openapi-next 1.0.0

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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +211 -0
  3. package/bun.lock +2154 -0
  4. package/dist/constants.d.ts +23 -0
  5. package/dist/constants.js +26 -0
  6. package/dist/decorators/api-basic.decorator.d.ts +1 -0
  7. package/dist/decorators/api-basic.decorator.js +7 -0
  8. package/dist/decorators/api-bearer.decorator.d.ts +1 -0
  9. package/dist/decorators/api-bearer.decorator.js +7 -0
  10. package/dist/decorators/api-body.decorator.d.ts +16 -0
  11. package/dist/decorators/api-body.decorator.js +22 -0
  12. package/dist/decorators/api-callbacks.decorator.d.ts +2 -0
  13. package/dist/decorators/api-callbacks.decorator.js +8 -0
  14. package/dist/decorators/api-consumes.decorator.d.ts +1 -0
  15. package/dist/decorators/api-consumes.decorator.js +8 -0
  16. package/dist/decorators/api-cookie.decorator.d.ts +1 -0
  17. package/dist/decorators/api-cookie.decorator.js +7 -0
  18. package/dist/decorators/api-default-getter.decorator.d.ts +2 -0
  19. package/dist/decorators/api-default-getter.decorator.js +12 -0
  20. package/dist/decorators/api-exclude-controller.decorator.d.ts +1 -0
  21. package/dist/decorators/api-exclude-controller.decorator.js +8 -0
  22. package/dist/decorators/api-exclude-endpoint.decorator.d.ts +1 -0
  23. package/dist/decorators/api-exclude-endpoint.decorator.js +10 -0
  24. package/dist/decorators/api-extension.decorator.d.ts +1 -0
  25. package/dist/decorators/api-extension.decorator.js +38 -0
  26. package/dist/decorators/api-extra-models.decorator.d.ts +1 -0
  27. package/dist/decorators/api-extra-models.decorator.js +17 -0
  28. package/dist/decorators/api-header.decorator.d.ts +7 -0
  29. package/dist/decorators/api-header.decorator.js +37 -0
  30. package/dist/decorators/api-hide-property.decorator.d.ts +1 -0
  31. package/dist/decorators/api-hide-property.decorator.js +6 -0
  32. package/dist/decorators/api-link.decorator.d.ts +7 -0
  33. package/dist/decorators/api-link.decorator.js +21 -0
  34. package/dist/decorators/api-oauth2.decorator.d.ts +1 -0
  35. package/dist/decorators/api-oauth2.decorator.js +7 -0
  36. package/dist/decorators/api-operation.decorator.d.ts +5 -0
  37. package/dist/decorators/api-operation.decorator.js +12 -0
  38. package/dist/decorators/api-param.decorator.d.ts +22 -0
  39. package/dist/decorators/api-param.decorator.js +17 -0
  40. package/dist/decorators/api-produces.decorator.d.ts +1 -0
  41. package/dist/decorators/api-produces.decorator.js +8 -0
  42. package/dist/decorators/api-property.decorator.d.ts +15 -0
  43. package/dist/decorators/api-property.decorator.js +48 -0
  44. package/dist/decorators/api-query-method.decorator.d.ts +1 -0
  45. package/dist/decorators/api-query-method.decorator.js +8 -0
  46. package/dist/decorators/api-query.decorator.d.ts +24 -0
  47. package/dist/decorators/api-query.decorator.js +25 -0
  48. package/dist/decorators/api-response.decorator.d.ts +39 -0
  49. package/dist/decorators/api-response.decorator.js +55 -0
  50. package/dist/decorators/api-schema.decorator.d.ts +6 -0
  51. package/dist/decorators/api-schema.decorator.js +8 -0
  52. package/dist/decorators/api-security-device-flow.decorator.d.ts +1 -0
  53. package/dist/decorators/api-security-device-flow.decorator.js +7 -0
  54. package/dist/decorators/api-security.decorator.d.ts +2 -0
  55. package/dist/decorators/api-security.decorator.js +25 -0
  56. package/dist/decorators/api-streaming-response.decorator.d.ts +7 -0
  57. package/dist/decorators/api-streaming-response.decorator.js +9 -0
  58. package/dist/decorators/api-tag-group.decorator.d.ts +11 -0
  59. package/dist/decorators/api-tag-group.decorator.js +13 -0
  60. package/dist/decorators/api-use-tags.decorator.d.ts +1 -0
  61. package/dist/decorators/api-use-tags.decorator.js +8 -0
  62. package/dist/decorators/helpers.d.ts +8 -0
  63. package/dist/decorators/helpers.js +123 -0
  64. package/dist/decorators/index.d.ts +28 -0
  65. package/dist/decorators/index.js +48 -0
  66. package/dist/document-builder.d.ts +29 -0
  67. package/dist/document-builder.js +142 -0
  68. package/dist/explorers/api-callbacks.explorer.d.ts +2 -0
  69. package/dist/explorers/api-callbacks.explorer.js +36 -0
  70. package/dist/explorers/api-consumes.explorer.d.ts +5 -0
  71. package/dist/explorers/api-consumes.explorer.js +11 -0
  72. package/dist/explorers/api-exclude-controller.explorer.d.ts +2 -0
  73. package/dist/explorers/api-exclude-controller.explorer.js +10 -0
  74. package/dist/explorers/api-exclude-endpoint.explorer.d.ts +2 -0
  75. package/dist/explorers/api-exclude-endpoint.explorer.js +6 -0
  76. package/dist/explorers/api-extra-models.explorer.d.ts +3 -0
  77. package/dist/explorers/api-extra-models.explorer.js +11 -0
  78. package/dist/explorers/api-headers.explorer.d.ts +7 -0
  79. package/dist/explorers/api-headers.explorer.js +9 -0
  80. package/dist/explorers/api-operation.explorer.d.ts +2 -0
  81. package/dist/explorers/api-operation.explorer.js +43 -0
  82. package/dist/explorers/api-parameters.explorer.d.ts +71 -0
  83. package/dist/explorers/api-parameters.explorer.js +47 -0
  84. package/dist/explorers/api-produces.explorer.d.ts +5 -0
  85. package/dist/explorers/api-produces.explorer.js +11 -0
  86. package/dist/explorers/api-response.explorer.d.ts +13 -0
  87. package/dist/explorers/api-response.explorer.js +103 -0
  88. package/dist/explorers/api-security.explorer.d.ts +5 -0
  89. package/dist/explorers/api-security.explorer.js +13 -0
  90. package/dist/explorers/api-use-tags.explorer.d.ts +5 -0
  91. package/dist/explorers/api-use-tags.explorer.js +18 -0
  92. package/dist/extra/swagger-shim.d.ts +100 -0
  93. package/dist/extra/swagger-shim.js +367 -0
  94. package/dist/fixtures/document.base.d.ts +2 -0
  95. package/dist/fixtures/document.base.js +16 -0
  96. package/dist/index.d.ts +7 -0
  97. package/dist/index.js +23 -0
  98. package/dist/interfaces/callback-object.interface.d.ts +12 -0
  99. package/dist/interfaces/callback-object.interface.js +2 -0
  100. package/dist/interfaces/denormalized-doc-resolvers.interface.d.ts +7 -0
  101. package/dist/interfaces/denormalized-doc-resolvers.interface.js +2 -0
  102. package/dist/interfaces/denormalized-doc.interface.d.ts +8 -0
  103. package/dist/interfaces/denormalized-doc.interface.js +2 -0
  104. package/dist/interfaces/enum-schema-attributes.interface.d.ts +2 -0
  105. package/dist/interfaces/enum-schema-attributes.interface.js +2 -0
  106. package/dist/interfaces/index.d.ts +3 -0
  107. package/dist/interfaces/index.js +18 -0
  108. package/dist/interfaces/module-route.interface.d.ts +2 -0
  109. package/dist/interfaces/module-route.interface.js +2 -0
  110. package/dist/interfaces/open-api-spec.interface.d.ts +252 -0
  111. package/dist/interfaces/open-api-spec.interface.js +2 -0
  112. package/dist/interfaces/schema-object-metadata.interface.d.ts +30 -0
  113. package/dist/interfaces/schema-object-metadata.interface.js +2 -0
  114. package/dist/interfaces/swagger-custom-options.interface.d.ts +24 -0
  115. package/dist/interfaces/swagger-custom-options.interface.js +2 -0
  116. package/dist/interfaces/swagger-document-options.interface.d.ts +10 -0
  117. package/dist/interfaces/swagger-document-options.interface.js +2 -0
  118. package/dist/interfaces/swagger-ui-init-options.interface.d.ts +7 -0
  119. package/dist/interfaces/swagger-ui-init-options.interface.js +2 -0
  120. package/dist/interfaces/swagger-ui-options.interface.d.ts +15 -0
  121. package/dist/interfaces/swagger-ui-options.interface.js +2 -0
  122. package/dist/plugin/compiler-plugin.d.ts +2 -0
  123. package/dist/plugin/compiler-plugin.js +30 -0
  124. package/dist/plugin/index.d.ts +2 -0
  125. package/dist/plugin/index.js +18 -0
  126. package/dist/plugin/merge-options.d.ts +17 -0
  127. package/dist/plugin/merge-options.js +37 -0
  128. package/dist/plugin/metadata-loader.d.ts +7 -0
  129. package/dist/plugin/metadata-loader.js +51 -0
  130. package/dist/plugin/plugin-constants.d.ts +3 -0
  131. package/dist/plugin/plugin-constants.js +6 -0
  132. package/dist/plugin/plugin-debug-logger.d.ts +5 -0
  133. package/dist/plugin/plugin-debug-logger.js +7 -0
  134. package/dist/plugin/utils/ast-utils.d.ts +30 -0
  135. package/dist/plugin/utils/ast-utils.js +273 -0
  136. package/dist/plugin/utils/is-filename-matched.util.d.ts +1 -0
  137. package/dist/plugin/utils/is-filename-matched.util.js +5 -0
  138. package/dist/plugin/utils/plugin-utils.d.ts +30 -0
  139. package/dist/plugin/utils/plugin-utils.js +307 -0
  140. package/dist/plugin/utils/type-reference-to-identifier.util.d.ts +7 -0
  141. package/dist/plugin/utils/type-reference-to-identifier.util.js +52 -0
  142. package/dist/plugin/visitors/abstract.visitor.d.ts +4 -0
  143. package/dist/plugin/visitors/abstract.visitor.js +30 -0
  144. package/dist/plugin/visitors/controller-class.visitor.d.ts +20 -0
  145. package/dist/plugin/visitors/controller-class.visitor.js +265 -0
  146. package/dist/plugin/visitors/model-class.visitor.d.ts +35 -0
  147. package/dist/plugin/visitors/model-class.visitor.js +514 -0
  148. package/dist/plugin/visitors/readonly.visitor.d.ts +21 -0
  149. package/dist/plugin/visitors/readonly.visitor.js +40 -0
  150. package/dist/services/constants.d.ts +1 -0
  151. package/dist/services/constants.js +4 -0
  152. package/dist/services/decorators-properties.d.ts +21 -0
  153. package/dist/services/decorators-properties.js +149 -0
  154. package/dist/services/mimetype-content-wrapper.d.ts +4 -0
  155. package/dist/services/mimetype-content-wrapper.js +11 -0
  156. package/dist/services/model-properties-accessor.d.ts +6 -0
  157. package/dist/services/model-properties-accessor.js +37 -0
  158. package/dist/services/parameter-metadata-accessor.d.ts +22 -0
  159. package/dist/services/parameter-metadata-accessor.js +41 -0
  160. package/dist/services/parameters-metadata-mapper.d.ts +9 -0
  161. package/dist/services/parameters-metadata-mapper.js +38 -0
  162. package/dist/services/response-object-factory.d.ts +28 -0
  163. package/dist/services/response-object-factory.js +120 -0
  164. package/dist/services/response-object-mapper.d.ts +39 -0
  165. package/dist/services/response-object-mapper.js +38 -0
  166. package/dist/services/schema-object-factory.d.ts +156 -0
  167. package/dist/services/schema-object-factory.js +471 -0
  168. package/dist/services/swagger-types-mapper.d.ts +260 -0
  169. package/dist/services/swagger-types-mapper.js +107 -0
  170. package/dist/storages/global-parameters.storage.d.ts +8 -0
  171. package/dist/storages/global-parameters.storage.js +22 -0
  172. package/dist/storages/global-responses.storage.d.ts +10 -0
  173. package/dist/storages/global-responses.storage.js +21 -0
  174. package/dist/swagger-explorer.d.ts +41 -0
  175. package/dist/swagger-explorer.js +326 -0
  176. package/dist/swagger-module.d.ts +27 -0
  177. package/dist/swagger-module.js +223 -0
  178. package/dist/swagger-scanner.d.ts +25 -0
  179. package/dist/swagger-scanner.js +116 -0
  180. package/dist/swagger-transformer.d.ts +4 -0
  181. package/dist/swagger-transformer.js +22 -0
  182. package/dist/swagger-ui/constants.d.ts +3 -0
  183. package/dist/swagger-ui/constants.js +132 -0
  184. package/dist/swagger-ui/helpers.d.ts +2 -0
  185. package/dist/swagger-ui/helpers.js +16 -0
  186. package/dist/swagger-ui/index.d.ts +1 -0
  187. package/dist/swagger-ui/index.js +17 -0
  188. package/dist/swagger-ui/swagger-ui.d.ts +4 -0
  189. package/dist/swagger-ui/swagger-ui.js +62 -0
  190. package/dist/type-helpers/index.d.ts +4 -0
  191. package/dist/type-helpers/index.js +20 -0
  192. package/dist/type-helpers/intersection-type.helper.d.ts +8 -0
  193. package/dist/type-helpers/intersection-type.helper.js +42 -0
  194. package/dist/type-helpers/mapped-types.utils.d.ts +2 -0
  195. package/dist/type-helpers/mapped-types.utils.js +31 -0
  196. package/dist/type-helpers/omit-type.helper.d.ts +2 -0
  197. package/dist/type-helpers/omit-type.helper.js +40 -0
  198. package/dist/type-helpers/partial-type.helper.d.ts +4 -0
  199. package/dist/type-helpers/partial-type.helper.js +49 -0
  200. package/dist/type-helpers/pick-type.helper.d.ts +2 -0
  201. package/dist/type-helpers/pick-type.helper.js +40 -0
  202. package/dist/types/swagger-enum.type.d.ts +1 -0
  203. package/dist/types/swagger-enum.type.js +2 -0
  204. package/dist/utils/assign-two-levels-deep.d.ts +1 -0
  205. package/dist/utils/assign-two-levels-deep.js +12 -0
  206. package/dist/utils/enum.utils.d.ts +9 -0
  207. package/dist/utils/enum.utils.js +65 -0
  208. package/dist/utils/extend-metadata.util.d.ts +2 -0
  209. package/dist/utils/extend-metadata.util.js +11 -0
  210. package/dist/utils/get-global-prefix.d.ts +2 -0
  211. package/dist/utils/get-global-prefix.js +7 -0
  212. package/dist/utils/get-schema-path.util.d.ts +4 -0
  213. package/dist/utils/get-schema-path.util.js +26 -0
  214. package/dist/utils/index.d.ts +1 -0
  215. package/dist/utils/index.js +17 -0
  216. package/dist/utils/is-body-parameter.util.d.ts +2 -0
  217. package/dist/utils/is-body-parameter.util.js +6 -0
  218. package/dist/utils/is-built-in-type.util.d.ts +2 -0
  219. package/dist/utils/is-built-in-type.util.js +8 -0
  220. package/dist/utils/is-date-ctor.util.d.ts +2 -0
  221. package/dist/utils/is-date-ctor.util.js +6 -0
  222. package/dist/utils/merge-and-uniq.util.d.ts +1 -0
  223. package/dist/utils/merge-and-uniq.util.js +7 -0
  224. package/dist/utils/normalize-rel-path.d.ts +1 -0
  225. package/dist/utils/normalize-rel-path.js +7 -0
  226. package/dist/utils/remove-undefined-keys.d.ts +5 -0
  227. package/dist/utils/remove-undefined-keys.js +11 -0
  228. package/dist/utils/resolve-path.util.d.ts +1 -0
  229. package/dist/utils/resolve-path.util.js +7 -0
  230. package/dist/utils/reverse-object-keys.util.d.ts +1 -0
  231. package/dist/utils/reverse-object-keys.util.js +11 -0
  232. package/dist/utils/sort-object-lexicographically.d.ts +5 -0
  233. package/dist/utils/sort-object-lexicographically.js +11 -0
  234. package/dist/utils/strip-last-slash.util.d.ts +1 -0
  235. package/dist/utils/strip-last-slash.util.js +8 -0
  236. package/dist/utils/validate-global-prefix.util.d.ts +1 -0
  237. package/dist/utils/validate-global-prefix.util.js +5 -0
  238. package/dist/utils/validate-path.util.d.ts +1 -0
  239. package/dist/utils/validate-path.util.js +5 -0
  240. package/eslint.config.mjs +47 -0
  241. package/nest-cli.json +6 -0
  242. package/package.json +116 -0
  243. package/plugin.js +10 -0
  244. package/tsconfig.build.json +21 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PickType = PickType;
4
+ const mapped_types_1 = require("@nestjs/mapped-types");
5
+ const lodash_1 = require("lodash");
6
+ const constants_1 = require("../constants");
7
+ const decorators_1 = require("../decorators");
8
+ const metadata_loader_1 = require("../plugin/metadata-loader");
9
+ const model_properties_accessor_1 = require("../services/model-properties-accessor");
10
+ const mapped_types_utils_1 = require("./mapped-types.utils");
11
+ const modelPropertiesAccessor = new model_properties_accessor_1.ModelPropertiesAccessor();
12
+ function PickType(classRef, keys) {
13
+ const fields = modelPropertiesAccessor
14
+ .getModelProperties(classRef.prototype)
15
+ .filter((item) => keys.includes(item));
16
+ const isInheritedPredicate = (propertyKey) => keys.includes(propertyKey);
17
+ class PickTypeClass {
18
+ constructor() {
19
+ (0, mapped_types_1.inheritPropertyInitializers)(this, classRef, isInheritedPredicate);
20
+ }
21
+ }
22
+ (0, mapped_types_1.inheritValidationMetadata)(classRef, PickTypeClass, isInheritedPredicate);
23
+ (0, mapped_types_1.inheritTransformationMetadata)(classRef, PickTypeClass, isInheritedPredicate);
24
+ function applyFields(fields) {
25
+ (0, mapped_types_utils_1.clonePluginMetadataFactory)(PickTypeClass, classRef.prototype, (metadata) => (0, lodash_1.pick)(metadata, keys));
26
+ fields.forEach((propertyKey) => {
27
+ const metadata = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES, classRef.prototype, propertyKey);
28
+ const decoratorFactory = (0, decorators_1.ApiProperty)(metadata);
29
+ decoratorFactory(PickTypeClass.prototype, propertyKey);
30
+ });
31
+ }
32
+ applyFields(fields);
33
+ metadata_loader_1.MetadataLoader.addRefreshHook(() => {
34
+ const fields = modelPropertiesAccessor
35
+ .getModelProperties(classRef.prototype)
36
+ .filter((item) => keys.includes(item));
37
+ applyFields(fields);
38
+ });
39
+ return PickTypeClass;
40
+ }
@@ -0,0 +1 @@
1
+ export type SwaggerEnumType = string[] | number[] | (string | number)[] | Record<number, string>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function assignTwoLevelsDeep<TObject, T>(_dest: TObject, ...args: T[]): TObject & T;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assignTwoLevelsDeep = assignTwoLevelsDeep;
4
+ function assignTwoLevelsDeep(_dest, ...args) {
5
+ const dest = _dest;
6
+ for (const arg of args) {
7
+ for (const [key, value] of Object.entries(arg !== null && arg !== void 0 ? arg : {})) {
8
+ dest[key] = Object.assign(Object.assign({}, dest[key]), value);
9
+ }
10
+ }
11
+ return dest;
12
+ }
@@ -0,0 +1,9 @@
1
+ import { SchemaObjectMetadata } from '../interfaces/schema-object-metadata.interface';
2
+ import { SwaggerEnumType } from '../types/swagger-enum.type';
3
+ export declare function getEnumValues(enumType: SwaggerEnumType | (() => SwaggerEnumType)): string[] | number[];
4
+ export declare function getEnumType(values: (string | number)[]): 'string' | 'number';
5
+ export declare function addEnumArraySchema(paramDefinition: Partial<Record<'schema' | 'isArray' | 'enumName' | 'enumSchema', any>>, decoratorOptions: Partial<Record<'enum' | 'enumName' | 'enumSchema', any>>): void;
6
+ export declare function addEnumSchema(paramDefinition: Partial<Record<string, any>>, decoratorOptions: Partial<Record<string, any>>): void;
7
+ export declare const isEnumArray: <T extends Partial<Record<"isArray" | "enum", any>>>(obj: Record<string, any>) => obj is T;
8
+ export declare const isEnumDefined: <T extends Partial<Record<"enum", any>>>(obj: Record<string, any>) => obj is T;
9
+ export declare const isEnumMetadata: (metadata: SchemaObjectMetadata) => any;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEnumMetadata = exports.isEnumDefined = exports.isEnumArray = void 0;
4
+ exports.getEnumValues = getEnumValues;
5
+ exports.getEnumType = getEnumType;
6
+ exports.addEnumArraySchema = addEnumArraySchema;
7
+ exports.addEnumSchema = addEnumSchema;
8
+ const lodash_1 = require("lodash");
9
+ function getEnumValues(enumType) {
10
+ if (typeof enumType === 'function') {
11
+ return getEnumValues(enumType());
12
+ }
13
+ if (Array.isArray(enumType)) {
14
+ return enumType;
15
+ }
16
+ if (typeof enumType !== 'object') {
17
+ return [];
18
+ }
19
+ const numericValues = Object.values(enumType)
20
+ .filter((value) => typeof value === 'number')
21
+ .map((value) => value.toString());
22
+ return Object.keys(enumType)
23
+ .filter((key) => !numericValues.includes(key))
24
+ .map((key) => enumType[key]);
25
+ }
26
+ function getEnumType(values) {
27
+ const hasString = values.filter(lodash_1.isString).length > 0;
28
+ return hasString ? 'string' : 'number';
29
+ }
30
+ function addEnumArraySchema(paramDefinition, decoratorOptions) {
31
+ const paramSchema = paramDefinition.schema || {};
32
+ paramDefinition.schema = paramSchema;
33
+ paramSchema.type = 'array';
34
+ delete paramDefinition.isArray;
35
+ const enumValues = getEnumValues(decoratorOptions.enum);
36
+ paramSchema.items = {
37
+ type: getEnumType(enumValues),
38
+ enum: enumValues
39
+ };
40
+ if (decoratorOptions.enumName) {
41
+ paramDefinition.enumName = decoratorOptions.enumName;
42
+ }
43
+ if (decoratorOptions.enumSchema) {
44
+ paramDefinition.enumSchema = decoratorOptions.enumSchema;
45
+ }
46
+ }
47
+ function addEnumSchema(paramDefinition, decoratorOptions) {
48
+ const paramSchema = paramDefinition.schema || {};
49
+ const enumValues = getEnumValues(decoratorOptions.enum);
50
+ paramDefinition.schema = paramSchema;
51
+ paramSchema.enum = enumValues;
52
+ paramSchema.type = getEnumType(enumValues);
53
+ if (decoratorOptions.enumName) {
54
+ paramDefinition.enumName = decoratorOptions.enumName;
55
+ }
56
+ if (decoratorOptions.enumSchema) {
57
+ paramDefinition.enumSchema = decoratorOptions.enumSchema;
58
+ }
59
+ }
60
+ const isEnumArray = (obj) => obj.isArray && obj.enum;
61
+ exports.isEnumArray = isEnumArray;
62
+ const isEnumDefined = (obj) => obj.enum;
63
+ exports.isEnumDefined = isEnumDefined;
64
+ const isEnumMetadata = (metadata) => { var _a; return metadata.enum || (metadata.isArray && ((_a = metadata.items) === null || _a === void 0 ? void 0 : _a['enum'])); };
65
+ exports.isEnumMetadata = isEnumMetadata;
@@ -0,0 +1,2 @@
1
+ import 'reflect-metadata';
2
+ export declare function extendMetadata<T extends Record<string, any>[] = any[]>(metadata: T, metakey: string, target: object): any;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendMetadata = extendMetadata;
4
+ require("reflect-metadata");
5
+ function extendMetadata(metadata, metakey, target) {
6
+ const existingMetadata = Reflect.getMetadata(metakey, target);
7
+ if (!existingMetadata) {
8
+ return metadata;
9
+ }
10
+ return existingMetadata.concat(metadata);
11
+ }
@@ -0,0 +1,2 @@
1
+ import { INestApplication } from '@nestjs/common';
2
+ export declare function getGlobalPrefix(app: INestApplication): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGlobalPrefix = getGlobalPrefix;
4
+ function getGlobalPrefix(app) {
5
+ const internalConfigRef = app.config;
6
+ return (internalConfigRef && internalConfigRef.getGlobalPrefix()) || '';
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare function getSchemaPath(model: string | Function): string;
2
+ export declare function refs(...models: Function[]): {
3
+ $ref: string;
4
+ }[];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSchemaPath = getSchemaPath;
4
+ exports.refs = refs;
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const constants_1 = require("../constants");
7
+ function getSchemaPath(model) {
8
+ const modelName = (0, shared_utils_1.isString)(model) ? model : getSchemaNameByClass(model);
9
+ return `#/components/schemas/${modelName}`;
10
+ }
11
+ function getSchemaNameByClass(target) {
12
+ var _a;
13
+ if (!target || typeof target !== 'function') {
14
+ return '';
15
+ }
16
+ const customSchema = Reflect.getOwnMetadata(constants_1.DECORATORS.API_SCHEMA, target);
17
+ if (!customSchema || customSchema.length === 0) {
18
+ return target.name;
19
+ }
20
+ return (_a = customSchema[customSchema.length - 1].name) !== null && _a !== void 0 ? _a : target.name;
21
+ }
22
+ function refs(...models) {
23
+ return models.map((item) => ({
24
+ $ref: getSchemaPath(item.name)
25
+ }));
26
+ }
@@ -0,0 +1 @@
1
+ export * from './get-schema-path.util';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-schema-path.util"), exports);
@@ -0,0 +1,2 @@
1
+ import { ParamWithTypeMetadata } from '../services/parameter-metadata-accessor';
2
+ export declare function isBodyParameter(param: ParamWithTypeMetadata): boolean;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBodyParameter = isBodyParameter;
4
+ function isBodyParameter(param) {
5
+ return param.in === 'body';
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Type } from '@nestjs/common';
2
+ export declare function isBuiltInType(type: Type<unknown> | Function | string): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBuiltInType = isBuiltInType;
4
+ const lodash_1 = require("lodash");
5
+ const constants_1 = require("../services/constants");
6
+ function isBuiltInType(type) {
7
+ return (0, lodash_1.isFunction)(type) && constants_1.BUILT_IN_TYPES.some((item) => item === type);
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Type } from '@nestjs/common';
2
+ export declare function isDateCtor(type: Type<unknown> | Function | string): boolean;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDateCtor = isDateCtor;
4
+ function isDateCtor(type) {
5
+ return type === Date;
6
+ }
@@ -0,0 +1 @@
1
+ export declare function mergeAndUniq<T = any>(a?: unknown, b?: unknown): T;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeAndUniq = mergeAndUniq;
4
+ const lodash_1 = require("lodash");
5
+ function mergeAndUniq(a = [], b = []) {
6
+ return (0, lodash_1.uniq)((0, lodash_1.merge)(a, b));
7
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeRelPath(input: string): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeRelPath = normalizeRelPath;
4
+ function normalizeRelPath(input) {
5
+ const output = input.replace(/\/\/+/g, '/');
6
+ return output;
7
+ }
@@ -0,0 +1,5 @@
1
+ export declare function removeUndefinedKeys(obj: {
2
+ [x: string]: any;
3
+ }): {
4
+ [x: string]: any;
5
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeUndefinedKeys = removeUndefinedKeys;
4
+ function removeUndefinedKeys(obj) {
5
+ Object.entries(obj).forEach(([key, value]) => {
6
+ if (value === undefined) {
7
+ delete obj[key];
8
+ }
9
+ });
10
+ return obj;
11
+ }
@@ -0,0 +1 @@
1
+ export declare function resolvePath(path: string): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvePath = resolvePath;
4
+ const pathLib = require("path");
5
+ function resolvePath(path) {
6
+ return path ? pathLib.resolve(path) : path;
7
+ }
@@ -0,0 +1 @@
1
+ export declare function reverseObjectKeys(originalObject: Record<string, any>): Record<string, any>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reverseObjectKeys = reverseObjectKeys;
4
+ function reverseObjectKeys(originalObject) {
5
+ const reversedObject = {};
6
+ const keys = Object.keys(originalObject).reverse();
7
+ for (const key of keys) {
8
+ reversedObject[key] = originalObject[key];
9
+ }
10
+ return reversedObject;
11
+ }
@@ -0,0 +1,5 @@
1
+ export declare function sortObjectLexicographically(obj: {
2
+ [key: string]: any;
3
+ }): {
4
+ [key: string]: any;
5
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortObjectLexicographically = sortObjectLexicographically;
4
+ function sortObjectLexicographically(obj) {
5
+ const sortedKeys = Object.keys(obj).sort();
6
+ const sortedObj = {};
7
+ for (const key of sortedKeys) {
8
+ sortedObj[key] = obj[key];
9
+ }
10
+ return sortedObj;
11
+ }
@@ -0,0 +1 @@
1
+ export declare function stripLastSlash(path: string): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripLastSlash = stripLastSlash;
4
+ function stripLastSlash(path) {
5
+ return path && path[path.length - 1] === '/'
6
+ ? path.slice(0, path.length - 1)
7
+ : path;
8
+ }
@@ -0,0 +1 @@
1
+ export declare const validateGlobalPrefix: (globalPrefix: string) => boolean;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateGlobalPrefix = void 0;
4
+ const validateGlobalPrefix = (globalPrefix) => globalPrefix && !globalPrefix.match(/^(\/?)$/);
5
+ exports.validateGlobalPrefix = validateGlobalPrefix;
@@ -0,0 +1 @@
1
+ export declare const validatePath: (inputPath: string) => string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePath = void 0;
4
+ const validatePath = (inputPath) => inputPath.charAt(0) !== '/' ? '/' + inputPath : inputPath;
5
+ exports.validatePath = validatePath;
@@ -0,0 +1,47 @@
1
+ // @ts-check
2
+ import eslint from '@eslint/js';
3
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
4
+ import globals from 'globals';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: ['tests/**'],
10
+ },
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommendedTypeChecked,
13
+ eslintPluginPrettierRecommended,
14
+ {
15
+ languageOptions: {
16
+ globals: {
17
+ ...globals.node,
18
+ ...globals.jest,
19
+ },
20
+ ecmaVersion: 5,
21
+ sourceType: 'module',
22
+ parserOptions: {
23
+ projectService: true,
24
+ tsconfigRootDir: import.meta.dirname,
25
+ },
26
+ },
27
+ },
28
+ {
29
+ rules: {
30
+ '@typescript-eslint/no-explicit-any': 'off',
31
+ '@typescript-eslint/no-unsafe-assignment': 'off',
32
+ '@typescript-eslint/no-unsafe-call': 'off',
33
+ '@typescript-eslint/no-unsafe-member-access': 'off',
34
+ '@typescript-eslint/no-unsafe-function-type': 'off',
35
+ '@typescript-eslint/no-unsafe-argument': 'off',
36
+ '@typescript-eslint/no-unsafe-return': 'off',
37
+ '@typescript-eslint/require-await': 'warn',
38
+ '@typescript-eslint/no-unused-vars': 'off',
39
+ '@typescript-eslint/unbound-method': 'off',
40
+ '@typescript-eslint/no-unsafe-enum-comparison': 'off',
41
+ '@typescript-eslint/no-redundant-type-constituents': 'warn',
42
+ '@typescript-eslint/only-throw-error': 'warn',
43
+ 'no-useless-escape': 'off',
44
+ '@typescript-eslint/no-require-imports': 'off'
45
+ },
46
+ },
47
+ );
package/nest-cli.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
3
+ "collection": "@nestjs/schematics",
4
+ "sourceRoot": "e2e",
5
+ "entryFile": "e2e/manual-e2e"
6
+ }
package/package.json ADDED
@@ -0,0 +1,116 @@
1
+ {
2
+ "name": "nestjs-openapi-next",
3
+ "version": "1.0.0",
4
+ "description": "A fork of @nestjs/swagger support OAS 3.2",
5
+ "author": "undownding",
6
+ "license": "MIT",
7
+ "repository": "https://github.com/undownding/nestjs-openapi-next",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "format": "prettier \"lib/**/*.ts\" --write",
13
+ "lint": "eslint 'lib/**/*.ts' --fix",
14
+ "prepublish:next": "npm run build",
15
+ "publish:next": "npm publish --access public --tag next",
16
+ "prepublish:npm": "npm run build",
17
+ "publish:npm": "npm publish --access public",
18
+ "prepare": "npm run build",
19
+ "test": "jest",
20
+ "test:dev": "jest --watch",
21
+ "test:e2e": "jest --config e2e/jest-e2e.json",
22
+ "prerelease": "npm run build",
23
+ "release": "release-it",
24
+ "---manual-tests---": "",
25
+ "start": "nest start",
26
+ "start:dev": "nest start --watch",
27
+ "start:debug": "nest start --watch --debug"
28
+ },
29
+ "dependencies": {
30
+ "@microsoft/tsdoc": "0.16.0",
31
+ "@nestjs/mapped-types": "2.1.0",
32
+ "js-yaml": "4.1.1",
33
+ "lodash": "4.17.21",
34
+ "path-to-regexp": "8.3.0",
35
+ "swagger-ui-dist": "5.30.2"
36
+ },
37
+ "devDependencies": {
38
+ "@commitlint/cli": "20.2.0",
39
+ "@commitlint/config-angular": "20.2.0",
40
+ "@eslint/eslintrc": "3.3.3",
41
+ "@eslint/js": "9.39.2",
42
+ "@fastify/static": "8.3.0",
43
+ "@nestjs/common": "11.1.11",
44
+ "@nestjs/core": "11.1.11",
45
+ "@nestjs/platform-express": "11.1.11",
46
+ "@nestjs/platform-fastify": "11.1.11",
47
+ "@types/jest": "30.0.0",
48
+ "@types/js-yaml": "4.0.9",
49
+ "@types/lodash": "4.17.21",
50
+ "@types/node": "24.10.4",
51
+ "class-transformer": "0.5.1",
52
+ "class-validator": "0.14.3",
53
+ "eslint": "9.39.2",
54
+ "eslint-config-prettier": "10.1.8",
55
+ "eslint-plugin-prettier": "5.5.4",
56
+ "express": "5.2.1",
57
+ "fastify": "5.6.2",
58
+ "globals": "16.5.0",
59
+ "husky": "9.1.7",
60
+ "jest": "30.2.0",
61
+ "lerna-changelog": "2.2.0",
62
+ "lint-staged": "16.2.7",
63
+ "openapi-types": "12.1.3",
64
+ "prettier": "3.7.4",
65
+ "prettier-v2": "npm:prettier@2.8.8",
66
+ "reflect-metadata": "0.2.2",
67
+ "release-it": "19.2.2",
68
+ "supertest": "7.1.4",
69
+ "swagger-parser": "10.0.3",
70
+ "ts-jest": "29.4.6",
71
+ "typescript": "5.9.3",
72
+ "typescript-eslint": "8.51.0"
73
+ },
74
+ "peerDependencies": {
75
+ "@fastify/static": "^8.0.0",
76
+ "@nestjs/common": "^11.0.1",
77
+ "@nestjs/core": "^11.0.1",
78
+ "class-transformer": "*",
79
+ "class-validator": "*",
80
+ "reflect-metadata": "^0.1.12 || ^0.2.0"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "@fastify/static": {
84
+ "optional": true
85
+ },
86
+ "class-transformer": {
87
+ "optional": true
88
+ },
89
+ "class-validator": {
90
+ "optional": true
91
+ }
92
+ },
93
+ "lint-staged": {
94
+ "*.ts": [
95
+ "prettier --write",
96
+ "git add -f"
97
+ ]
98
+ },
99
+ "husky": {
100
+ "hooks": {
101
+ "pre-commit": "lint-staged",
102
+ "commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS"
103
+ }
104
+ },
105
+ "changelog": {
106
+ "labels": {
107
+ "feature": "Features",
108
+ "bug": "Bug fixes",
109
+ "enhancement": "Enhancements",
110
+ "docs": "Docs",
111
+ "dependencies": "Dependencies",
112
+ "type: code style": "Code style tweaks",
113
+ "breaking change": "Breaking changes"
114
+ }
115
+ }
116
+ }
package/plugin.js ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ exports.__esModule = true;
6
+ const plugin = require('./dist/plugin');
7
+ __export(plugin);
8
+
9
+ /** Compatibility with ts-patch/ttypescript */
10
+ exports.default = (program, options) => plugin.before(options, program);
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "noImplicitAny": false,
7
+ "removeComments": true,
8
+ "noLib": false,
9
+ "emitDecoratorMetadata": true,
10
+ "experimentalDecorators": true,
11
+ "target": "es6",
12
+ "sourceMap": false,
13
+ "outDir": "./dist",
14
+ "rootDir": "./lib",
15
+ "skipLibCheck": true
16
+ },
17
+ "include": [
18
+ "lib/**/*"
19
+ ],
20
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "e2e"]
21
+ }