@tsed/schema 6.75.5 → 6.75.9
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/lib/components/lazyRefMapper.d.ts +1 -17
- package/lib/index.js +23 -8
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +24 -9
- package/lib/index.modern.js.map +1 -1
- package/lib/utils/ref.d.ts +2 -34
- package/package.json +5 -5
package/lib/index.modern.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { constantCase, pascalCase, camelCase } from 'change-case';
|
|
2
|
-
import { Store, decoratorTypeOf, nameOf,
|
|
2
|
+
import { Store, decoratorTypeOf, nameOf, cleanObject, isFunction, isPromise, isClass, isSymbol, isPrimitiveOrPrimitiveClass, isClassObject, isDate, isCollection, classOf, isArrowFn, primitiveOf, isArray, Hooks, uniq, isObject, uniqBy, deepMerge, toMap, Entity, DecoratorTypes, descriptorOf, Metadata, isPlainObject, isPrimitiveClass, ancestorsOf, mergeReducerBuilder, UnsupportedDecoratorType, decorateMethodsOf, isString, isNumber, useDecorators, StoreSet } from '@tsed/core';
|
|
3
3
|
import micromatch from 'micromatch';
|
|
4
4
|
|
|
5
5
|
const HTTP_STATUS_MESSAGES = {
|
|
@@ -308,21 +308,36 @@ function createRef(name, schema, options) {
|
|
|
308
308
|
const ref = {
|
|
309
309
|
$ref: `${host}/${name}`
|
|
310
310
|
};
|
|
311
|
+
const nullable = schema.nullable;
|
|
312
|
+
const readOnly = schema.get ? schema.get("readOnly") : undefined;
|
|
311
313
|
|
|
312
|
-
if (
|
|
314
|
+
if (nullable || readOnly) {
|
|
313
315
|
switch (options.specType) {
|
|
314
316
|
case SpecTypes.OPENAPI:
|
|
315
|
-
return {
|
|
316
|
-
nullable: true,
|
|
317
|
+
return cleanObject({
|
|
318
|
+
nullable: nullable ? true : undefined,
|
|
319
|
+
readOnly: readOnly ? true : undefined,
|
|
317
320
|
allOf: [ref]
|
|
318
|
-
};
|
|
321
|
+
});
|
|
319
322
|
|
|
320
323
|
case SpecTypes.JSON:
|
|
321
|
-
return {
|
|
322
|
-
|
|
324
|
+
return cleanObject({
|
|
325
|
+
readOnly,
|
|
326
|
+
oneOf: [nullable && {
|
|
323
327
|
type: "null"
|
|
324
|
-
}, ref]
|
|
325
|
-
};
|
|
328
|
+
}, ref].filter(Boolean)
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
case SpecTypes.SWAGGER:
|
|
332
|
+
// unsupported
|
|
333
|
+
if (readOnly) {
|
|
334
|
+
return {
|
|
335
|
+
readOnly,
|
|
336
|
+
allOf: [ref]
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
break;
|
|
326
341
|
}
|
|
327
342
|
}
|
|
328
343
|
|