@rvoh/psychic 0.31.1 → 0.31.2
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/cjs/src/openapi-renderer/body-segment.js +2 -12
- package/dist/cjs/src/openapi-renderer/helpers/schemaToRef.js +9 -0
- package/dist/cjs/src/openapi-renderer/serializer.js +3 -2
- package/dist/esm/src/openapi-renderer/body-segment.js +2 -12
- package/dist/esm/src/openapi-renderer/helpers/schemaToRef.js +6 -0
- package/dist/esm/src/openapi-renderer/serializer.js +3 -2
- package/dist/types/src/openapi-renderer/body-segment.d.ts +0 -6
- package/dist/types/src/openapi-renderer/helpers/schemaToRef.d.ts +3 -0
- package/dist/types/src/openapi-renderer/serializer.d.ts +2 -11
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ const dream_1 = require("@rvoh/dream");
|
|
|
30
30
|
const index_js_1 = __importDefault(require("../psychic-app/index.js"));
|
|
31
31
|
const isBlankDescription_js_1 = __importDefault(require("./helpers/isBlankDescription.js"));
|
|
32
32
|
const primitiveOpenapiStatementToOpenapi_js_1 = __importStar(require("./helpers/primitiveOpenapiStatementToOpenapi.js"));
|
|
33
|
+
const schemaToRef_js_1 = __importDefault(require("./helpers/schemaToRef.js"));
|
|
33
34
|
const serializer_js_1 = __importDefault(require("./serializer.js"));
|
|
34
35
|
class OpenapiBodySegmentRenderer {
|
|
35
36
|
controllerClass;
|
|
@@ -93,7 +94,7 @@ class OpenapiBodySegmentRenderer {
|
|
|
93
94
|
case '$ref':
|
|
94
95
|
return this.refStatement(bodySegment);
|
|
95
96
|
case '$schema':
|
|
96
|
-
return
|
|
97
|
+
return (0, schemaToRef_js_1.default)(bodySegment);
|
|
97
98
|
case '$serializer':
|
|
98
99
|
return this.serializerStatement(bodySegment);
|
|
99
100
|
case '$serializable':
|
|
@@ -393,17 +394,6 @@ The following values will be allowed:
|
|
|
393
394
|
...serializableRef,
|
|
394
395
|
});
|
|
395
396
|
}
|
|
396
|
-
/**
|
|
397
|
-
* @internal
|
|
398
|
-
*
|
|
399
|
-
* recursively a $schema statement
|
|
400
|
-
*/
|
|
401
|
-
schemaRefStatement(bodySegment) {
|
|
402
|
-
const schemaRefBodySegment = bodySegment;
|
|
403
|
-
return {
|
|
404
|
-
$ref: `#/components/schemas/${schemaRefBodySegment.$schema.replace(/^#\/components\/schemas\//, '')}`,
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
397
|
/**
|
|
408
398
|
* @internal
|
|
409
399
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = schemaToRef;
|
|
4
|
+
function schemaToRef(bodySegment) {
|
|
5
|
+
const schemaRefBodySegment = bodySegment;
|
|
6
|
+
return {
|
|
7
|
+
$ref: `#/components/schemas/${schemaRefBodySegment.$schema.replace(/^#\/components\/schemas\//, '')}`,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -9,6 +9,7 @@ const UnexpectedUndefined_js_1 = __importDefault(require("../error/UnexpectedUnd
|
|
|
9
9
|
const EnvInternal_js_1 = __importDefault(require("../helpers/EnvInternal.js"));
|
|
10
10
|
const index_js_1 = __importDefault(require("../psychic-app/index.js"));
|
|
11
11
|
const body_segment_js_1 = __importDefault(require("./body-segment.js"));
|
|
12
|
+
const schemaToRef_js_1 = __importDefault(require("./helpers/schemaToRef.js"));
|
|
12
13
|
class OpenapiSerializerRenderer {
|
|
13
14
|
openapiName;
|
|
14
15
|
controllerClass;
|
|
@@ -129,7 +130,7 @@ Error: ${this.serializerClass.name} missing explicit serializer definition for $
|
|
|
129
130
|
{
|
|
130
131
|
allOf: [
|
|
131
132
|
{ ...finalOutputForSerializerKey },
|
|
132
|
-
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
133
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => (0, schemaToRef_js_1.default)({ $schema: schema })) },
|
|
133
134
|
],
|
|
134
135
|
},
|
|
135
136
|
],
|
|
@@ -142,7 +143,7 @@ Error: ${this.serializerClass.name} missing explicit serializer definition for $
|
|
|
142
143
|
[serializerKey]: {
|
|
143
144
|
allOf: [
|
|
144
145
|
{ ...finalOutputForSerializerKey },
|
|
145
|
-
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
146
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => (0, schemaToRef_js_1.default)({ $schema: schema })) },
|
|
146
147
|
],
|
|
147
148
|
},
|
|
148
149
|
};
|
|
@@ -2,6 +2,7 @@ import { inferSerializerFromDreamOrViewModel, openapiShorthandPrimitiveTypes, }
|
|
|
2
2
|
import PsychicApp from '../psychic-app/index.js';
|
|
3
3
|
import isBlankDescription from './helpers/isBlankDescription.js';
|
|
4
4
|
import primitiveOpenapiStatementToOpenapi, { maybeNullPrimitiveToPrimitive, } from './helpers/primitiveOpenapiStatementToOpenapi.js';
|
|
5
|
+
import schemaToRef from './helpers/schemaToRef.js';
|
|
5
6
|
import OpenapiSerializerRenderer from './serializer.js';
|
|
6
7
|
export default class OpenapiBodySegmentRenderer {
|
|
7
8
|
controllerClass;
|
|
@@ -65,7 +66,7 @@ export default class OpenapiBodySegmentRenderer {
|
|
|
65
66
|
case '$ref':
|
|
66
67
|
return this.refStatement(bodySegment);
|
|
67
68
|
case '$schema':
|
|
68
|
-
return
|
|
69
|
+
return schemaToRef(bodySegment);
|
|
69
70
|
case '$serializer':
|
|
70
71
|
return this.serializerStatement(bodySegment);
|
|
71
72
|
case '$serializable':
|
|
@@ -365,17 +366,6 @@ The following values will be allowed:
|
|
|
365
366
|
...serializableRef,
|
|
366
367
|
});
|
|
367
368
|
}
|
|
368
|
-
/**
|
|
369
|
-
* @internal
|
|
370
|
-
*
|
|
371
|
-
* recursively a $schema statement
|
|
372
|
-
*/
|
|
373
|
-
schemaRefStatement(bodySegment) {
|
|
374
|
-
const schemaRefBodySegment = bodySegment;
|
|
375
|
-
return {
|
|
376
|
-
$ref: `#/components/schemas/${schemaRefBodySegment.$schema.replace(/^#\/components\/schemas\//, '')}`,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
369
|
/**
|
|
380
370
|
* @internal
|
|
381
371
|
*
|
|
@@ -4,6 +4,7 @@ import UnexpectedUndefined from '../error/UnexpectedUndefined.js';
|
|
|
4
4
|
import EnvInternal from '../helpers/EnvInternal.js';
|
|
5
5
|
import PsychicApp from '../psychic-app/index.js';
|
|
6
6
|
import OpenapiBodySegmentRenderer from './body-segment.js';
|
|
7
|
+
import schemaToRef from './helpers/schemaToRef.js';
|
|
7
8
|
export default class OpenapiSerializerRenderer {
|
|
8
9
|
openapiName;
|
|
9
10
|
controllerClass;
|
|
@@ -124,7 +125,7 @@ Error: ${this.serializerClass.name} missing explicit serializer definition for $
|
|
|
124
125
|
{
|
|
125
126
|
allOf: [
|
|
126
127
|
{ ...finalOutputForSerializerKey },
|
|
127
|
-
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
128
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => schemaToRef({ $schema: schema })) },
|
|
128
129
|
],
|
|
129
130
|
},
|
|
130
131
|
],
|
|
@@ -137,7 +138,7 @@ Error: ${this.serializerClass.name} missing explicit serializer definition for $
|
|
|
137
138
|
[serializerKey]: {
|
|
138
139
|
allOf: [
|
|
139
140
|
{ ...finalOutputForSerializerKey },
|
|
140
|
-
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
141
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => schemaToRef({ $schema: schema })) },
|
|
141
142
|
],
|
|
142
143
|
},
|
|
143
144
|
};
|
|
@@ -109,12 +109,6 @@ export default class OpenapiBodySegmentRenderer {
|
|
|
109
109
|
*/
|
|
110
110
|
private serializerStatement;
|
|
111
111
|
private serializableStatement;
|
|
112
|
-
/**
|
|
113
|
-
* @internal
|
|
114
|
-
*
|
|
115
|
-
* recursively a $schema statement
|
|
116
|
-
*/
|
|
117
|
-
private schemaRefStatement;
|
|
118
112
|
/**
|
|
119
113
|
* @internal
|
|
120
114
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DreamSerializer,
|
|
1
|
+
import { DreamSerializer, OpenapiSchemaObject } from '@rvoh/dream';
|
|
2
2
|
import PsychicController from '../controller/index.js';
|
|
3
|
+
import { OpenapiBodyTarget } from './body-segment.js';
|
|
3
4
|
export default class OpenapiSerializerRenderer {
|
|
4
5
|
private openapiName;
|
|
5
6
|
private controllerClass;
|
|
@@ -64,13 +65,3 @@ export default class OpenapiSerializerRenderer {
|
|
|
64
65
|
private addMultiSerializerAssociationToOutput;
|
|
65
66
|
private accountForNullableOption;
|
|
66
67
|
}
|
|
67
|
-
export type OpenapiEndpointParseResults = {
|
|
68
|
-
results: OpenapiSchemaBody;
|
|
69
|
-
extraComponents: {
|
|
70
|
-
[key: string]: OpenapiSchemaObject;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export type OpenapiBodySegment = OpenapiSchemaBodyShorthand | OpenapiShorthandPrimitiveTypes | {
|
|
74
|
-
description: string;
|
|
75
|
-
} | undefined;
|
|
76
|
-
export type OpenapiBodyTarget = 'request' | 'response';
|