nicot 1.1.34 → 1.1.35
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/dist/index.cjs +25 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +25 -1
- package/dist/index.mjs.map +3 -3
- package/dist/src/utility/metadata.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -322,7 +322,8 @@ var ParseBoolObjectPipe = class {
|
|
|
322
322
|
|
|
323
323
|
// src/decorators/property.ts
|
|
324
324
|
function swaggerDecorator(options, injected = {}) {
|
|
325
|
-
|
|
325
|
+
const notRequiredButHasDefault = options.required == null && options.default != null;
|
|
326
|
+
const apiPropertyDec = (0, import_swagger2.ApiProperty)({
|
|
326
327
|
default: options.default,
|
|
327
328
|
required: !!(options.required && options.default == null),
|
|
328
329
|
example: options.default,
|
|
@@ -330,6 +331,18 @@ function swaggerDecorator(options, injected = {}) {
|
|
|
330
331
|
...injected,
|
|
331
332
|
...options.propertyExtras || {}
|
|
332
333
|
});
|
|
334
|
+
if (notRequiredButHasDefault) {
|
|
335
|
+
return (0, import_nesties3.MergePropertyDecorators)([
|
|
336
|
+
apiPropertyDec,
|
|
337
|
+
Metadata.set(
|
|
338
|
+
"notRequiredButHasDefault",
|
|
339
|
+
true,
|
|
340
|
+
"notRequiredButHasDefaultFields"
|
|
341
|
+
)
|
|
342
|
+
]);
|
|
343
|
+
} else {
|
|
344
|
+
return apiPropertyDec;
|
|
345
|
+
}
|
|
333
346
|
}
|
|
334
347
|
function validatorDecorator(options) {
|
|
335
348
|
const decs = [];
|
|
@@ -2082,6 +2095,17 @@ var RestfulFactory = class _RestfulFactory {
|
|
|
2082
2095
|
}
|
|
2083
2096
|
}
|
|
2084
2097
|
}
|
|
2098
|
+
const notRequiredButHasDefaultFields = getSpecificFields(
|
|
2099
|
+
this.entityClass,
|
|
2100
|
+
"notRequiredButHasDefault"
|
|
2101
|
+
).filter((f) => !outputFieldsToOmit.has(f));
|
|
2102
|
+
for (const field of notRequiredButHasDefaultFields) {
|
|
2103
|
+
const oldApiProperty = (0, import_nesties10.getApiProperty)(resultDto, field);
|
|
2104
|
+
(0, import_swagger7.ApiProperty)({
|
|
2105
|
+
...oldApiProperty,
|
|
2106
|
+
required: true
|
|
2107
|
+
})(resultDto.prototype, field);
|
|
2108
|
+
}
|
|
2085
2109
|
const res = (0, import_nesties11.RenameClass)(
|
|
2086
2110
|
resultDto,
|
|
2087
2111
|
`${this.getEntityClassName()}ResultDto`
|