@tsed/schema 6.75.7 → 6.75.8
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
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
import { JsonLazyRef } from "../domain/JsonLazyRef";
|
|
2
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions):
|
|
4
|
-
$ref: string;
|
|
5
|
-
} | {
|
|
6
|
-
nullable: boolean;
|
|
7
|
-
allOf: {
|
|
8
|
-
$ref: string;
|
|
9
|
-
}[];
|
|
10
|
-
oneOf?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
oneOf: ({
|
|
13
|
-
$ref: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: string;
|
|
16
|
-
})[];
|
|
17
|
-
nullable?: undefined;
|
|
18
|
-
allOf?: undefined;
|
|
19
|
-
};
|
|
3
|
+
export declare function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions): any;
|
package/lib/index.js
CHANGED
|
@@ -312,21 +312,36 @@ function createRef(name, schema, options) {
|
|
|
312
312
|
const ref = {
|
|
313
313
|
$ref: `${host}/${name}`
|
|
314
314
|
};
|
|
315
|
+
const nullable = schema.nullable;
|
|
316
|
+
const readOnly = schema.get ? schema.get("readOnly") : undefined;
|
|
315
317
|
|
|
316
|
-
if (
|
|
318
|
+
if (nullable || readOnly) {
|
|
317
319
|
switch (options.specType) {
|
|
318
320
|
case exports.SpecTypes.OPENAPI:
|
|
319
|
-
return {
|
|
320
|
-
nullable: true,
|
|
321
|
+
return core.cleanObject({
|
|
322
|
+
nullable: nullable ? true : undefined,
|
|
323
|
+
readOnly: readOnly ? true : undefined,
|
|
321
324
|
allOf: [ref]
|
|
322
|
-
};
|
|
325
|
+
});
|
|
323
326
|
|
|
324
327
|
case exports.SpecTypes.JSON:
|
|
325
|
-
return {
|
|
326
|
-
|
|
328
|
+
return core.cleanObject({
|
|
329
|
+
readOnly,
|
|
330
|
+
oneOf: [nullable && {
|
|
327
331
|
type: "null"
|
|
328
|
-
}, ref]
|
|
329
|
-
};
|
|
332
|
+
}, ref].filter(Boolean)
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
case exports.SpecTypes.SWAGGER:
|
|
336
|
+
// unsupported
|
|
337
|
+
if (readOnly) {
|
|
338
|
+
return {
|
|
339
|
+
readOnly,
|
|
340
|
+
allOf: [ref]
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
break;
|
|
330
345
|
}
|
|
331
346
|
}
|
|
332
347
|
|