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.
- package/LICENSE +21 -0
- package/README.md +211 -0
- package/bun.lock +2154 -0
- package/dist/constants.d.ts +23 -0
- package/dist/constants.js +26 -0
- package/dist/decorators/api-basic.decorator.d.ts +1 -0
- package/dist/decorators/api-basic.decorator.js +7 -0
- package/dist/decorators/api-bearer.decorator.d.ts +1 -0
- package/dist/decorators/api-bearer.decorator.js +7 -0
- package/dist/decorators/api-body.decorator.d.ts +16 -0
- package/dist/decorators/api-body.decorator.js +22 -0
- package/dist/decorators/api-callbacks.decorator.d.ts +2 -0
- package/dist/decorators/api-callbacks.decorator.js +8 -0
- package/dist/decorators/api-consumes.decorator.d.ts +1 -0
- package/dist/decorators/api-consumes.decorator.js +8 -0
- package/dist/decorators/api-cookie.decorator.d.ts +1 -0
- package/dist/decorators/api-cookie.decorator.js +7 -0
- package/dist/decorators/api-default-getter.decorator.d.ts +2 -0
- package/dist/decorators/api-default-getter.decorator.js +12 -0
- package/dist/decorators/api-exclude-controller.decorator.d.ts +1 -0
- package/dist/decorators/api-exclude-controller.decorator.js +8 -0
- package/dist/decorators/api-exclude-endpoint.decorator.d.ts +1 -0
- package/dist/decorators/api-exclude-endpoint.decorator.js +10 -0
- package/dist/decorators/api-extension.decorator.d.ts +1 -0
- package/dist/decorators/api-extension.decorator.js +38 -0
- package/dist/decorators/api-extra-models.decorator.d.ts +1 -0
- package/dist/decorators/api-extra-models.decorator.js +17 -0
- package/dist/decorators/api-header.decorator.d.ts +7 -0
- package/dist/decorators/api-header.decorator.js +37 -0
- package/dist/decorators/api-hide-property.decorator.d.ts +1 -0
- package/dist/decorators/api-hide-property.decorator.js +6 -0
- package/dist/decorators/api-link.decorator.d.ts +7 -0
- package/dist/decorators/api-link.decorator.js +21 -0
- package/dist/decorators/api-oauth2.decorator.d.ts +1 -0
- package/dist/decorators/api-oauth2.decorator.js +7 -0
- package/dist/decorators/api-operation.decorator.d.ts +5 -0
- package/dist/decorators/api-operation.decorator.js +12 -0
- package/dist/decorators/api-param.decorator.d.ts +22 -0
- package/dist/decorators/api-param.decorator.js +17 -0
- package/dist/decorators/api-produces.decorator.d.ts +1 -0
- package/dist/decorators/api-produces.decorator.js +8 -0
- package/dist/decorators/api-property.decorator.d.ts +15 -0
- package/dist/decorators/api-property.decorator.js +48 -0
- package/dist/decorators/api-query-method.decorator.d.ts +1 -0
- package/dist/decorators/api-query-method.decorator.js +8 -0
- package/dist/decorators/api-query.decorator.d.ts +24 -0
- package/dist/decorators/api-query.decorator.js +25 -0
- package/dist/decorators/api-response.decorator.d.ts +39 -0
- package/dist/decorators/api-response.decorator.js +55 -0
- package/dist/decorators/api-schema.decorator.d.ts +6 -0
- package/dist/decorators/api-schema.decorator.js +8 -0
- package/dist/decorators/api-security-device-flow.decorator.d.ts +1 -0
- package/dist/decorators/api-security-device-flow.decorator.js +7 -0
- package/dist/decorators/api-security.decorator.d.ts +2 -0
- package/dist/decorators/api-security.decorator.js +25 -0
- package/dist/decorators/api-streaming-response.decorator.d.ts +7 -0
- package/dist/decorators/api-streaming-response.decorator.js +9 -0
- package/dist/decorators/api-tag-group.decorator.d.ts +11 -0
- package/dist/decorators/api-tag-group.decorator.js +13 -0
- package/dist/decorators/api-use-tags.decorator.d.ts +1 -0
- package/dist/decorators/api-use-tags.decorator.js +8 -0
- package/dist/decorators/helpers.d.ts +8 -0
- package/dist/decorators/helpers.js +123 -0
- package/dist/decorators/index.d.ts +28 -0
- package/dist/decorators/index.js +48 -0
- package/dist/document-builder.d.ts +29 -0
- package/dist/document-builder.js +142 -0
- package/dist/explorers/api-callbacks.explorer.d.ts +2 -0
- package/dist/explorers/api-callbacks.explorer.js +36 -0
- package/dist/explorers/api-consumes.explorer.d.ts +5 -0
- package/dist/explorers/api-consumes.explorer.js +11 -0
- package/dist/explorers/api-exclude-controller.explorer.d.ts +2 -0
- package/dist/explorers/api-exclude-controller.explorer.js +10 -0
- package/dist/explorers/api-exclude-endpoint.explorer.d.ts +2 -0
- package/dist/explorers/api-exclude-endpoint.explorer.js +6 -0
- package/dist/explorers/api-extra-models.explorer.d.ts +3 -0
- package/dist/explorers/api-extra-models.explorer.js +11 -0
- package/dist/explorers/api-headers.explorer.d.ts +7 -0
- package/dist/explorers/api-headers.explorer.js +9 -0
- package/dist/explorers/api-operation.explorer.d.ts +2 -0
- package/dist/explorers/api-operation.explorer.js +43 -0
- package/dist/explorers/api-parameters.explorer.d.ts +71 -0
- package/dist/explorers/api-parameters.explorer.js +47 -0
- package/dist/explorers/api-produces.explorer.d.ts +5 -0
- package/dist/explorers/api-produces.explorer.js +11 -0
- package/dist/explorers/api-response.explorer.d.ts +13 -0
- package/dist/explorers/api-response.explorer.js +103 -0
- package/dist/explorers/api-security.explorer.d.ts +5 -0
- package/dist/explorers/api-security.explorer.js +13 -0
- package/dist/explorers/api-use-tags.explorer.d.ts +5 -0
- package/dist/explorers/api-use-tags.explorer.js +18 -0
- package/dist/extra/swagger-shim.d.ts +100 -0
- package/dist/extra/swagger-shim.js +367 -0
- package/dist/fixtures/document.base.d.ts +2 -0
- package/dist/fixtures/document.base.js +16 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/interfaces/callback-object.interface.d.ts +12 -0
- package/dist/interfaces/callback-object.interface.js +2 -0
- package/dist/interfaces/denormalized-doc-resolvers.interface.d.ts +7 -0
- package/dist/interfaces/denormalized-doc-resolvers.interface.js +2 -0
- package/dist/interfaces/denormalized-doc.interface.d.ts +8 -0
- package/dist/interfaces/denormalized-doc.interface.js +2 -0
- package/dist/interfaces/enum-schema-attributes.interface.d.ts +2 -0
- package/dist/interfaces/enum-schema-attributes.interface.js +2 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +18 -0
- package/dist/interfaces/module-route.interface.d.ts +2 -0
- package/dist/interfaces/module-route.interface.js +2 -0
- package/dist/interfaces/open-api-spec.interface.d.ts +252 -0
- package/dist/interfaces/open-api-spec.interface.js +2 -0
- package/dist/interfaces/schema-object-metadata.interface.d.ts +30 -0
- package/dist/interfaces/schema-object-metadata.interface.js +2 -0
- package/dist/interfaces/swagger-custom-options.interface.d.ts +24 -0
- package/dist/interfaces/swagger-custom-options.interface.js +2 -0
- package/dist/interfaces/swagger-document-options.interface.d.ts +10 -0
- package/dist/interfaces/swagger-document-options.interface.js +2 -0
- package/dist/interfaces/swagger-ui-init-options.interface.d.ts +7 -0
- package/dist/interfaces/swagger-ui-init-options.interface.js +2 -0
- package/dist/interfaces/swagger-ui-options.interface.d.ts +15 -0
- package/dist/interfaces/swagger-ui-options.interface.js +2 -0
- package/dist/plugin/compiler-plugin.d.ts +2 -0
- package/dist/plugin/compiler-plugin.js +30 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.js +18 -0
- package/dist/plugin/merge-options.d.ts +17 -0
- package/dist/plugin/merge-options.js +37 -0
- package/dist/plugin/metadata-loader.d.ts +7 -0
- package/dist/plugin/metadata-loader.js +51 -0
- package/dist/plugin/plugin-constants.d.ts +3 -0
- package/dist/plugin/plugin-constants.js +6 -0
- package/dist/plugin/plugin-debug-logger.d.ts +5 -0
- package/dist/plugin/plugin-debug-logger.js +7 -0
- package/dist/plugin/utils/ast-utils.d.ts +30 -0
- package/dist/plugin/utils/ast-utils.js +273 -0
- package/dist/plugin/utils/is-filename-matched.util.d.ts +1 -0
- package/dist/plugin/utils/is-filename-matched.util.js +5 -0
- package/dist/plugin/utils/plugin-utils.d.ts +30 -0
- package/dist/plugin/utils/plugin-utils.js +307 -0
- package/dist/plugin/utils/type-reference-to-identifier.util.d.ts +7 -0
- package/dist/plugin/utils/type-reference-to-identifier.util.js +52 -0
- package/dist/plugin/visitors/abstract.visitor.d.ts +4 -0
- package/dist/plugin/visitors/abstract.visitor.js +30 -0
- package/dist/plugin/visitors/controller-class.visitor.d.ts +20 -0
- package/dist/plugin/visitors/controller-class.visitor.js +265 -0
- package/dist/plugin/visitors/model-class.visitor.d.ts +35 -0
- package/dist/plugin/visitors/model-class.visitor.js +514 -0
- package/dist/plugin/visitors/readonly.visitor.d.ts +21 -0
- package/dist/plugin/visitors/readonly.visitor.js +40 -0
- package/dist/services/constants.d.ts +1 -0
- package/dist/services/constants.js +4 -0
- package/dist/services/decorators-properties.d.ts +21 -0
- package/dist/services/decorators-properties.js +149 -0
- package/dist/services/mimetype-content-wrapper.d.ts +4 -0
- package/dist/services/mimetype-content-wrapper.js +11 -0
- package/dist/services/model-properties-accessor.d.ts +6 -0
- package/dist/services/model-properties-accessor.js +37 -0
- package/dist/services/parameter-metadata-accessor.d.ts +22 -0
- package/dist/services/parameter-metadata-accessor.js +41 -0
- package/dist/services/parameters-metadata-mapper.d.ts +9 -0
- package/dist/services/parameters-metadata-mapper.js +38 -0
- package/dist/services/response-object-factory.d.ts +28 -0
- package/dist/services/response-object-factory.js +120 -0
- package/dist/services/response-object-mapper.d.ts +39 -0
- package/dist/services/response-object-mapper.js +38 -0
- package/dist/services/schema-object-factory.d.ts +156 -0
- package/dist/services/schema-object-factory.js +471 -0
- package/dist/services/swagger-types-mapper.d.ts +260 -0
- package/dist/services/swagger-types-mapper.js +107 -0
- package/dist/storages/global-parameters.storage.d.ts +8 -0
- package/dist/storages/global-parameters.storage.js +22 -0
- package/dist/storages/global-responses.storage.d.ts +10 -0
- package/dist/storages/global-responses.storage.js +21 -0
- package/dist/swagger-explorer.d.ts +41 -0
- package/dist/swagger-explorer.js +326 -0
- package/dist/swagger-module.d.ts +27 -0
- package/dist/swagger-module.js +223 -0
- package/dist/swagger-scanner.d.ts +25 -0
- package/dist/swagger-scanner.js +116 -0
- package/dist/swagger-transformer.d.ts +4 -0
- package/dist/swagger-transformer.js +22 -0
- package/dist/swagger-ui/constants.d.ts +3 -0
- package/dist/swagger-ui/constants.js +132 -0
- package/dist/swagger-ui/helpers.d.ts +2 -0
- package/dist/swagger-ui/helpers.js +16 -0
- package/dist/swagger-ui/index.d.ts +1 -0
- package/dist/swagger-ui/index.js +17 -0
- package/dist/swagger-ui/swagger-ui.d.ts +4 -0
- package/dist/swagger-ui/swagger-ui.js +62 -0
- package/dist/type-helpers/index.d.ts +4 -0
- package/dist/type-helpers/index.js +20 -0
- package/dist/type-helpers/intersection-type.helper.d.ts +8 -0
- package/dist/type-helpers/intersection-type.helper.js +42 -0
- package/dist/type-helpers/mapped-types.utils.d.ts +2 -0
- package/dist/type-helpers/mapped-types.utils.js +31 -0
- package/dist/type-helpers/omit-type.helper.d.ts +2 -0
- package/dist/type-helpers/omit-type.helper.js +40 -0
- package/dist/type-helpers/partial-type.helper.d.ts +4 -0
- package/dist/type-helpers/partial-type.helper.js +49 -0
- package/dist/type-helpers/pick-type.helper.d.ts +2 -0
- package/dist/type-helpers/pick-type.helper.js +40 -0
- package/dist/types/swagger-enum.type.d.ts +1 -0
- package/dist/types/swagger-enum.type.js +2 -0
- package/dist/utils/assign-two-levels-deep.d.ts +1 -0
- package/dist/utils/assign-two-levels-deep.js +12 -0
- package/dist/utils/enum.utils.d.ts +9 -0
- package/dist/utils/enum.utils.js +65 -0
- package/dist/utils/extend-metadata.util.d.ts +2 -0
- package/dist/utils/extend-metadata.util.js +11 -0
- package/dist/utils/get-global-prefix.d.ts +2 -0
- package/dist/utils/get-global-prefix.js +7 -0
- package/dist/utils/get-schema-path.util.d.ts +4 -0
- package/dist/utils/get-schema-path.util.js +26 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/is-body-parameter.util.d.ts +2 -0
- package/dist/utils/is-body-parameter.util.js +6 -0
- package/dist/utils/is-built-in-type.util.d.ts +2 -0
- package/dist/utils/is-built-in-type.util.js +8 -0
- package/dist/utils/is-date-ctor.util.d.ts +2 -0
- package/dist/utils/is-date-ctor.util.js +6 -0
- package/dist/utils/merge-and-uniq.util.d.ts +1 -0
- package/dist/utils/merge-and-uniq.util.js +7 -0
- package/dist/utils/normalize-rel-path.d.ts +1 -0
- package/dist/utils/normalize-rel-path.js +7 -0
- package/dist/utils/remove-undefined-keys.d.ts +5 -0
- package/dist/utils/remove-undefined-keys.js +11 -0
- package/dist/utils/resolve-path.util.d.ts +1 -0
- package/dist/utils/resolve-path.util.js +7 -0
- package/dist/utils/reverse-object-keys.util.d.ts +1 -0
- package/dist/utils/reverse-object-keys.util.js +11 -0
- package/dist/utils/sort-object-lexicographically.d.ts +5 -0
- package/dist/utils/sort-object-lexicographically.js +11 -0
- package/dist/utils/strip-last-slash.util.d.ts +1 -0
- package/dist/utils/strip-last-slash.util.js +8 -0
- package/dist/utils/validate-global-prefix.util.d.ts +1 -0
- package/dist/utils/validate-global-prefix.util.js +5 -0
- package/dist/utils/validate-path.util.d.ts +1 -0
- package/dist/utils/validate-path.util.js +5 -0
- package/eslint.config.mjs +47 -0
- package/nest-cli.json +6 -0
- package/package.json +116 -0
- package/plugin.js +10 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decoratorsProperties = exports.decoratorsPropertiesMappingType = void 0;
|
|
4
|
+
var decoratorsPropertiesMappingType;
|
|
5
|
+
(function (decoratorsPropertiesMappingType) {
|
|
6
|
+
decoratorsPropertiesMappingType[decoratorsPropertiesMappingType["DIRECT"] = 0] = "DIRECT";
|
|
7
|
+
decoratorsPropertiesMappingType[decoratorsPropertiesMappingType["INDIRECT_VALUE"] = 1] = "INDIRECT_VALUE";
|
|
8
|
+
decoratorsPropertiesMappingType[decoratorsPropertiesMappingType["INDIRECT_ARGUMENT"] = 2] = "INDIRECT_ARGUMENT";
|
|
9
|
+
})(decoratorsPropertiesMappingType || (exports.decoratorsPropertiesMappingType = decoratorsPropertiesMappingType = {}));
|
|
10
|
+
exports.decoratorsProperties = [
|
|
11
|
+
{
|
|
12
|
+
mappingType: decoratorsPropertiesMappingType.DIRECT,
|
|
13
|
+
decorator: 'Min',
|
|
14
|
+
property: 'minimum',
|
|
15
|
+
value: undefined
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
mappingType: decoratorsPropertiesMappingType.DIRECT,
|
|
19
|
+
decorator: 'Max',
|
|
20
|
+
property: 'maximum',
|
|
21
|
+
value: undefined
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
mappingType: decoratorsPropertiesMappingType.DIRECT,
|
|
25
|
+
decorator: 'MinLength',
|
|
26
|
+
property: 'minLength',
|
|
27
|
+
value: undefined
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
mappingType: decoratorsPropertiesMappingType.DIRECT,
|
|
31
|
+
decorator: 'MaxLength',
|
|
32
|
+
property: 'maxLength',
|
|
33
|
+
value: undefined
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
37
|
+
decorator: 'ArrayNotEmpty',
|
|
38
|
+
property: 'minItems',
|
|
39
|
+
value: 1
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
43
|
+
decorator: 'IsPositive',
|
|
44
|
+
property: 'minimum',
|
|
45
|
+
value: 1
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
49
|
+
decorator: 'IsNegative',
|
|
50
|
+
property: 'maximum',
|
|
51
|
+
value: -1
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
55
|
+
decorator: 'ArrayUnique',
|
|
56
|
+
property: 'uniqueItems',
|
|
57
|
+
value: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
61
|
+
decorator: 'IsBase64',
|
|
62
|
+
property: 'format',
|
|
63
|
+
value: 'base64'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
67
|
+
decorator: 'IsCreditCard',
|
|
68
|
+
property: 'format',
|
|
69
|
+
value: 'credit-card'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
73
|
+
decorator: 'IsCurrency',
|
|
74
|
+
property: 'format',
|
|
75
|
+
value: 'currency'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
79
|
+
decorator: 'IsEmail',
|
|
80
|
+
property: 'format',
|
|
81
|
+
value: 'email'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
85
|
+
decorator: 'IsJSON',
|
|
86
|
+
property: 'format',
|
|
87
|
+
value: 'json'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
91
|
+
decorator: 'IsUrl',
|
|
92
|
+
property: 'format',
|
|
93
|
+
value: 'uri'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
97
|
+
decorator: 'IsUUID',
|
|
98
|
+
property: 'format',
|
|
99
|
+
value: 'uuid'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
103
|
+
decorator: 'IsMobilePhone',
|
|
104
|
+
property: 'format',
|
|
105
|
+
value: 'mobile-phone'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
109
|
+
decorator: 'IsAscii',
|
|
110
|
+
property: 'pattern',
|
|
111
|
+
value: '^[\\x00-\\x7F]+$'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
115
|
+
decorator: 'IsHexColor',
|
|
116
|
+
property: 'pattern',
|
|
117
|
+
value: '^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_VALUE,
|
|
121
|
+
decorator: 'IsHexadecimal',
|
|
122
|
+
property: 'pattern',
|
|
123
|
+
value: '^(0x|0h)?[0-9A-F]+$'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_ARGUMENT,
|
|
127
|
+
decorator: 'ArrayMinSize',
|
|
128
|
+
property: 'minItems',
|
|
129
|
+
value: undefined
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_ARGUMENT,
|
|
133
|
+
decorator: 'ArrayMaxSize',
|
|
134
|
+
property: 'maxItems',
|
|
135
|
+
value: undefined
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_ARGUMENT,
|
|
139
|
+
decorator: 'IsDivisibleBy',
|
|
140
|
+
property: 'multipleOf',
|
|
141
|
+
value: undefined
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
mappingType: decoratorsPropertiesMappingType.INDIRECT_ARGUMENT,
|
|
145
|
+
decorator: 'Contains',
|
|
146
|
+
property: 'pattern',
|
|
147
|
+
value: undefined
|
|
148
|
+
}
|
|
149
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MimetypeContentWrapper = void 0;
|
|
4
|
+
const remove_undefined_keys_1 = require("../utils/remove-undefined-keys");
|
|
5
|
+
class MimetypeContentWrapper {
|
|
6
|
+
wrap(mimetype, obj) {
|
|
7
|
+
const content = mimetype.reduce((acc, item) => (Object.assign(Object.assign({}, acc), { [item]: (0, remove_undefined_keys_1.removeUndefinedKeys)(obj) })), {});
|
|
8
|
+
return { content };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.MimetypeContentWrapper = MimetypeContentWrapper;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelPropertiesAccessor = void 0;
|
|
4
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
|
+
require("reflect-metadata");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const api_property_decorator_1 = require("../decorators/api-property.decorator");
|
|
8
|
+
const plugin_constants_1 = require("../plugin/plugin-constants");
|
|
9
|
+
class ModelPropertiesAccessor {
|
|
10
|
+
getModelProperties(prototype) {
|
|
11
|
+
const properties = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES_ARRAY, prototype) ||
|
|
12
|
+
[];
|
|
13
|
+
return properties
|
|
14
|
+
.filter(shared_utils_1.isString)
|
|
15
|
+
.filter((key) => key.charAt(0) === ':' && !(0, shared_utils_1.isFunction)(prototype[key]))
|
|
16
|
+
.map((key) => key.slice(1));
|
|
17
|
+
}
|
|
18
|
+
applyMetadataFactory(prototype) {
|
|
19
|
+
const classPrototype = prototype;
|
|
20
|
+
do {
|
|
21
|
+
if (!prototype.constructor) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!prototype.constructor[plugin_constants_1.METADATA_FACTORY_NAME]) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const metadata = prototype.constructor[plugin_constants_1.METADATA_FACTORY_NAME]();
|
|
28
|
+
const properties = Object.keys(metadata);
|
|
29
|
+
properties.forEach((key) => {
|
|
30
|
+
(0, api_property_decorator_1.createApiPropertyDecorator)(metadata[key], false)(classPrototype, key);
|
|
31
|
+
});
|
|
32
|
+
} while ((prototype = Reflect.getPrototypeOf(prototype)) &&
|
|
33
|
+
prototype !== Object.prototype &&
|
|
34
|
+
prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ModelPropertiesAccessor = ModelPropertiesAccessor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { EnumSchemaAttributes } from '../interfaces/enum-schema-attributes.interface';
|
|
3
|
+
import { ParameterLocation, SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
4
|
+
export interface ParamWithTypeMetadata {
|
|
5
|
+
name?: string | number | object;
|
|
6
|
+
type?: Type<unknown>;
|
|
7
|
+
in?: ParameterLocation | 'body' | typeof PARAM_TOKEN_PLACEHOLDER;
|
|
8
|
+
isArray?: boolean;
|
|
9
|
+
items?: SchemaObject;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
enum?: unknown[];
|
|
12
|
+
enumName?: string;
|
|
13
|
+
enumSchema?: EnumSchemaAttributes;
|
|
14
|
+
selfRequired?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type ParamsWithType = Record<string, ParamWithTypeMetadata>;
|
|
17
|
+
declare const PARAM_TOKEN_PLACEHOLDER = "placeholder";
|
|
18
|
+
export declare class ParameterMetadataAccessor {
|
|
19
|
+
explore(instance: object, prototype: Type<unknown>, method: Function): ParamsWithType;
|
|
20
|
+
private mapParamType;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParameterMetadataAccessor = void 0;
|
|
4
|
+
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
+
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const reverse_object_keys_util_1 = require("../utils/reverse-object-keys.util");
|
|
8
|
+
const PARAM_TOKEN_PLACEHOLDER = 'placeholder';
|
|
9
|
+
class ParameterMetadataAccessor {
|
|
10
|
+
explore(instance, prototype, method) {
|
|
11
|
+
const types = Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, instance, method.name);
|
|
12
|
+
if (!(types === null || types === void 0 ? void 0 : types.length)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const routeArgsMetadata = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, instance.constructor, method.name) || {};
|
|
16
|
+
const parametersWithType = (0, lodash_1.mapValues)((0, reverse_object_keys_util_1.reverseObjectKeys)(routeArgsMetadata), (param) => ({
|
|
17
|
+
type: types[param.index],
|
|
18
|
+
name: param.data,
|
|
19
|
+
required: true
|
|
20
|
+
}));
|
|
21
|
+
const excludePredicate = (val) => val.in === PARAM_TOKEN_PLACEHOLDER || (val.name && val.in === 'body');
|
|
22
|
+
const parameters = (0, lodash_1.omitBy)((0, lodash_1.mapValues)(parametersWithType, (val, key) => (Object.assign(Object.assign({}, val), { in: this.mapParamType(key) }))), excludePredicate);
|
|
23
|
+
return !(0, lodash_1.isEmpty)(parameters) ? parameters : undefined;
|
|
24
|
+
}
|
|
25
|
+
mapParamType(key) {
|
|
26
|
+
const keyPair = key.split(':');
|
|
27
|
+
switch (Number(keyPair[0])) {
|
|
28
|
+
case route_paramtypes_enum_1.RouteParamtypes.BODY:
|
|
29
|
+
return 'body';
|
|
30
|
+
case route_paramtypes_enum_1.RouteParamtypes.PARAM:
|
|
31
|
+
return 'path';
|
|
32
|
+
case route_paramtypes_enum_1.RouteParamtypes.QUERY:
|
|
33
|
+
return 'query';
|
|
34
|
+
case route_paramtypes_enum_1.RouteParamtypes.HEADERS:
|
|
35
|
+
return 'header';
|
|
36
|
+
default:
|
|
37
|
+
return PARAM_TOKEN_PLACEHOLDER;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ParameterMetadataAccessor = ParameterMetadataAccessor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { ModelPropertiesAccessor } from './model-properties-accessor';
|
|
3
|
+
import { ParamWithTypeMetadata, ParamsWithType } from './parameter-metadata-accessor';
|
|
4
|
+
export declare class ParametersMetadataMapper {
|
|
5
|
+
private readonly modelPropertiesAccessor;
|
|
6
|
+
constructor(modelPropertiesAccessor: ModelPropertiesAccessor);
|
|
7
|
+
transformModelToProperties(parameters: ParamsWithType): ParamWithTypeMetadata[];
|
|
8
|
+
mergeImplicitWithExplicit(key: string, prototype: Type<unknown>, param: ParamWithTypeMetadata): ParamWithTypeMetadata;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParametersMetadataMapper = void 0;
|
|
4
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const is_body_parameter_util_1 = require("../utils/is-body-parameter.util");
|
|
8
|
+
class ParametersMetadataMapper {
|
|
9
|
+
constructor(modelPropertiesAccessor) {
|
|
10
|
+
this.modelPropertiesAccessor = modelPropertiesAccessor;
|
|
11
|
+
}
|
|
12
|
+
transformModelToProperties(parameters) {
|
|
13
|
+
const properties = (0, lodash_1.flatMap)(parameters, (param) => {
|
|
14
|
+
if (!param || param.type === Object || !param.type) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
if (param.name) {
|
|
18
|
+
return param;
|
|
19
|
+
}
|
|
20
|
+
if ((0, is_body_parameter_util_1.isBodyParameter)(param)) {
|
|
21
|
+
const isCtor = param.type && (0, shared_utils_1.isFunction)(param.type);
|
|
22
|
+
const name = isCtor ? param.type.name : param.type;
|
|
23
|
+
return Object.assign(Object.assign({}, param), { name });
|
|
24
|
+
}
|
|
25
|
+
const { prototype } = param.type;
|
|
26
|
+
this.modelPropertiesAccessor.applyMetadataFactory(prototype);
|
|
27
|
+
const modelProperties = this.modelPropertiesAccessor.getModelProperties(prototype);
|
|
28
|
+
return modelProperties.map((key) => this.mergeImplicitWithExplicit(key, prototype, param));
|
|
29
|
+
});
|
|
30
|
+
return properties.filter(lodash_1.identity);
|
|
31
|
+
}
|
|
32
|
+
mergeImplicitWithExplicit(key, prototype, param) {
|
|
33
|
+
const reflectedParam = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES, prototype, key) ||
|
|
34
|
+
{};
|
|
35
|
+
return Object.assign(Object.assign(Object.assign({}, param), reflectedParam), { name: reflectedParam.name || key });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ParametersMetadataMapper = ParametersMetadataMapper;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApiResponseMetadata, ApiResponseSchemaHost } from '../decorators';
|
|
2
|
+
import { SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
3
|
+
export type FactoriesNeededByResponseFactory = {
|
|
4
|
+
linkName: (controllerKey: string, methodKey: string, fieldKey: string) => string;
|
|
5
|
+
operationId: (controllerKey: string, methodKey: string) => string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ResponseObjectFactory {
|
|
8
|
+
private readonly mimetypeContentWrapper;
|
|
9
|
+
private readonly modelPropertiesAccessor;
|
|
10
|
+
private readonly swaggerTypesMapper;
|
|
11
|
+
private readonly schemaObjectFactory;
|
|
12
|
+
private readonly responseObjectMapper;
|
|
13
|
+
create(response: ApiResponseMetadata, produces: string[], schemas: Record<string, SchemaObject>, factories: FactoriesNeededByResponseFactory): (ApiResponseSchemaHost & import("../decorators").ApiResponseCommonMetadata & {
|
|
14
|
+
example?: any;
|
|
15
|
+
}) | (ApiResponseSchemaHost & import("../decorators").ApiResponseCommonMetadata & {
|
|
16
|
+
examples?: {
|
|
17
|
+
[key: string]: import("../decorators").ApiResponseExamples;
|
|
18
|
+
};
|
|
19
|
+
}) | {
|
|
20
|
+
content: import("../interfaces/open-api-spec.interface").ContentObject;
|
|
21
|
+
} | {
|
|
22
|
+
content: {
|
|
23
|
+
[x: string]: {
|
|
24
|
+
[x: string]: any;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseObjectFactory = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const is_built_in_type_util_1 = require("../utils/is-built-in-type.util");
|
|
7
|
+
const remove_undefined_keys_1 = require("../utils/remove-undefined-keys");
|
|
8
|
+
const mimetype_content_wrapper_1 = require("./mimetype-content-wrapper");
|
|
9
|
+
const model_properties_accessor_1 = require("./model-properties-accessor");
|
|
10
|
+
const response_object_mapper_1 = require("./response-object-mapper");
|
|
11
|
+
const schema_object_factory_1 = require("./schema-object-factory");
|
|
12
|
+
const swagger_types_mapper_1 = require("./swagger-types-mapper");
|
|
13
|
+
class ResponseObjectFactory {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.mimetypeContentWrapper = new mimetype_content_wrapper_1.MimetypeContentWrapper();
|
|
16
|
+
this.modelPropertiesAccessor = new model_properties_accessor_1.ModelPropertiesAccessor();
|
|
17
|
+
this.swaggerTypesMapper = new swagger_types_mapper_1.SwaggerTypesMapper();
|
|
18
|
+
this.schemaObjectFactory = new schema_object_factory_1.SchemaObjectFactory(this.modelPropertiesAccessor, this.swaggerTypesMapper);
|
|
19
|
+
this.responseObjectMapper = new response_object_mapper_1.ResponseObjectMapper();
|
|
20
|
+
}
|
|
21
|
+
create(response, produces, schemas, factories) {
|
|
22
|
+
var _a;
|
|
23
|
+
const { type, isArray } = response;
|
|
24
|
+
response = (0, lodash_1.omit)(response, ['isArray']);
|
|
25
|
+
const isStreaming = response.isStreaming;
|
|
26
|
+
const streamingContentType = response.contentType;
|
|
27
|
+
if (isStreaming) {
|
|
28
|
+
const exampleKeys = ['example', 'examples'];
|
|
29
|
+
const contentType = streamingContentType || (produces === null || produces === void 0 ? void 0 : produces[0]);
|
|
30
|
+
let itemSchema;
|
|
31
|
+
if (type) {
|
|
32
|
+
if ((0, is_built_in_type_util_1.isBuiltInType)(type) || typeof type === 'string') {
|
|
33
|
+
const typeName = type && (0, lodash_1.isFunction)(type)
|
|
34
|
+
? type.name
|
|
35
|
+
: type;
|
|
36
|
+
const swaggerType = this.swaggerTypesMapper.mapTypeToOpenAPIType(typeName);
|
|
37
|
+
itemSchema = { type: swaggerType };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const name = this.schemaObjectFactory.exploreModelSchema(type, schemas);
|
|
41
|
+
itemSchema = { $ref: `#/components/schemas/${name}` };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const mediaTypeObject = (0, remove_undefined_keys_1.removeUndefinedKeys)(Object.assign({ itemSchema }, (0, lodash_1.pick)(response, exampleKeys)));
|
|
45
|
+
const keysToOmit = [...exampleKeys, 'type', 'isStreaming', 'contentType'];
|
|
46
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, keysToOmit)), (contentType
|
|
47
|
+
? { content: { [contentType]: mediaTypeObject } }
|
|
48
|
+
: undefined));
|
|
49
|
+
}
|
|
50
|
+
if (!type) {
|
|
51
|
+
return this.responseObjectMapper.wrapSchemaWithContent(response, produces);
|
|
52
|
+
}
|
|
53
|
+
if ((0, is_built_in_type_util_1.isBuiltInType)(type)) {
|
|
54
|
+
const typeName = type && (0, lodash_1.isFunction)(type) ? type.name : type;
|
|
55
|
+
const swaggerType = this.swaggerTypesMapper.mapTypeToOpenAPIType(typeName);
|
|
56
|
+
const exampleKeys = ['example', 'examples'];
|
|
57
|
+
if (isArray) {
|
|
58
|
+
const content = this.mimetypeContentWrapper.wrap(produces, {
|
|
59
|
+
schema: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: {
|
|
62
|
+
type: swaggerType
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, exampleKeys)), content);
|
|
67
|
+
}
|
|
68
|
+
const content = this.mimetypeContentWrapper.wrap(produces, {
|
|
69
|
+
schema: {
|
|
70
|
+
type: swaggerType
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, exampleKeys)), content);
|
|
74
|
+
}
|
|
75
|
+
const name = this.schemaObjectFactory.exploreModelSchema(type, schemas);
|
|
76
|
+
if ((0, lodash_1.isFunction)(type) && type.prototype) {
|
|
77
|
+
const { prototype } = type;
|
|
78
|
+
const links = {};
|
|
79
|
+
const properties = this.modelPropertiesAccessor.getModelProperties(prototype);
|
|
80
|
+
const generateLink = (controllerPrototype, method, parameter, field) => {
|
|
81
|
+
if (!factories) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const linkName = factories.linkName(controllerPrototype.constructor.name, method.name, field);
|
|
85
|
+
links[linkName] = {
|
|
86
|
+
operationId: factories.operationId(controllerPrototype.constructor.name, method.name),
|
|
87
|
+
parameters: {
|
|
88
|
+
[parameter]: `$response.body#/${field}`
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
for (const key of properties) {
|
|
93
|
+
const metadata = (_a = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES, prototype, key)) !== null && _a !== void 0 ? _a : {};
|
|
94
|
+
if (!metadata.link) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const linkedType = metadata.link();
|
|
98
|
+
const linkedGetterInfo = Reflect.getMetadata(constants_1.DECORATORS.API_DEFAULT_GETTER, linkedType.prototype);
|
|
99
|
+
if (!linkedGetterInfo) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const { getter, parameter, prototype: controllerPrototype } = linkedGetterInfo;
|
|
103
|
+
generateLink(controllerPrototype, getter, parameter, key);
|
|
104
|
+
}
|
|
105
|
+
const customLinks = Reflect.getMetadata(constants_1.DECORATORS.API_LINK, prototype);
|
|
106
|
+
for (const customLink of customLinks !== null && customLinks !== void 0 ? customLinks : []) {
|
|
107
|
+
const { method, parameter, field, prototype: controllerPrototype } = customLink;
|
|
108
|
+
generateLink(controllerPrototype, method, parameter, field);
|
|
109
|
+
}
|
|
110
|
+
if (!(0, lodash_1.isEmpty)(links)) {
|
|
111
|
+
response.links = Object.assign(links, response.links);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (isArray) {
|
|
115
|
+
return this.responseObjectMapper.toArrayRefObject(response, name, produces);
|
|
116
|
+
}
|
|
117
|
+
return this.responseObjectMapper.toRefObject(response, name, produces);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ResponseObjectFactory = ResponseObjectFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ApiResponseMetadata, ApiResponseSchemaHost } from '../decorators';
|
|
2
|
+
export declare class ResponseObjectMapper {
|
|
3
|
+
private readonly mimetypeContentWrapper;
|
|
4
|
+
toArrayRefObject(response: Record<string, any>, name: string, produces: string[]): {
|
|
5
|
+
content: import("../interfaces/open-api-spec.interface").ContentObject;
|
|
6
|
+
};
|
|
7
|
+
toRefObject(response: Record<string, any>, name: string, produces: string[]): {
|
|
8
|
+
content: import("../interfaces/open-api-spec.interface").ContentObject;
|
|
9
|
+
};
|
|
10
|
+
wrapSchemaWithContent(response: ApiResponseSchemaHost & ApiResponseMetadata, produces: string[]): (ApiResponseSchemaHost & import("../decorators").ApiResponseCommonMetadata & {
|
|
11
|
+
example?: any;
|
|
12
|
+
}) | (ApiResponseSchemaHost & import("../decorators").ApiResponseCommonMetadata & {
|
|
13
|
+
examples?: {
|
|
14
|
+
[key: string]: import("../decorators").ApiResponseExamples;
|
|
15
|
+
};
|
|
16
|
+
}) | {
|
|
17
|
+
content: import("../interfaces/open-api-spec.interface").ContentObject;
|
|
18
|
+
schema?: import("../interfaces/open-api-spec.interface").SchemaObject & Partial<import("../interfaces/open-api-spec.interface").ReferenceObject>;
|
|
19
|
+
status?: number | "default" | "1XX" | "2XX" | "3XX" | "4XX" | "5XX";
|
|
20
|
+
description?: string;
|
|
21
|
+
headers?: import("../interfaces/open-api-spec.interface").HeadersObject;
|
|
22
|
+
links?: import("../interfaces/open-api-spec.interface").LinksObject;
|
|
23
|
+
type?: import("@nestjs/common").Type<unknown> | Function | [Function] | string;
|
|
24
|
+
isArray?: boolean;
|
|
25
|
+
example?: any;
|
|
26
|
+
} | {
|
|
27
|
+
content: import("../interfaces/open-api-spec.interface").ContentObject;
|
|
28
|
+
schema?: import("../interfaces/open-api-spec.interface").SchemaObject & Partial<import("../interfaces/open-api-spec.interface").ReferenceObject>;
|
|
29
|
+
status?: number | "default" | "1XX" | "2XX" | "3XX" | "4XX" | "5XX";
|
|
30
|
+
description?: string;
|
|
31
|
+
headers?: import("../interfaces/open-api-spec.interface").HeadersObject;
|
|
32
|
+
links?: import("../interfaces/open-api-spec.interface").LinksObject;
|
|
33
|
+
type?: import("@nestjs/common").Type<unknown> | Function | [Function] | string;
|
|
34
|
+
isArray?: boolean;
|
|
35
|
+
examples?: {
|
|
36
|
+
[key: string]: import("../decorators").ApiResponseExamples;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseObjectMapper = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const mimetype_content_wrapper_1 = require("./mimetype-content-wrapper");
|
|
7
|
+
class ResponseObjectMapper {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.mimetypeContentWrapper = new mimetype_content_wrapper_1.MimetypeContentWrapper();
|
|
10
|
+
}
|
|
11
|
+
toArrayRefObject(response, name, produces) {
|
|
12
|
+
const exampleKeys = ['example', 'examples'];
|
|
13
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, exampleKeys)), this.mimetypeContentWrapper.wrap(produces, Object.assign({ schema: {
|
|
14
|
+
type: 'array',
|
|
15
|
+
items: {
|
|
16
|
+
$ref: (0, utils_1.getSchemaPath)(name)
|
|
17
|
+
}
|
|
18
|
+
} }, (0, lodash_1.pick)(response, exampleKeys))));
|
|
19
|
+
}
|
|
20
|
+
toRefObject(response, name, produces) {
|
|
21
|
+
const exampleKeys = ['example', 'examples'];
|
|
22
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, exampleKeys)), this.mimetypeContentWrapper.wrap(produces, Object.assign({ schema: {
|
|
23
|
+
$ref: (0, utils_1.getSchemaPath)(name)
|
|
24
|
+
} }, (0, lodash_1.pick)(response, exampleKeys))));
|
|
25
|
+
}
|
|
26
|
+
wrapSchemaWithContent(response, produces) {
|
|
27
|
+
if (!response.schema &&
|
|
28
|
+
!('example' in response) &&
|
|
29
|
+
!('examples' in response)) {
|
|
30
|
+
return response;
|
|
31
|
+
}
|
|
32
|
+
const exampleKeys = ['example', 'examples'];
|
|
33
|
+
const content = this.mimetypeContentWrapper.wrap(produces, Object.assign({ schema: response.schema }, (0, lodash_1.pick)(response, exampleKeys)));
|
|
34
|
+
const keysToOmit = [...exampleKeys, 'schema'];
|
|
35
|
+
return Object.assign(Object.assign({}, (0, lodash_1.omit)(response, keysToOmit)), content);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ResponseObjectMapper = ResponseObjectMapper;
|