@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.
@@ -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 this.schemaRefStatement(bodySegment);
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 this.schemaRefStatement(bodySegment);
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
  *
@@ -0,0 +1,6 @@
1
+ export default function schemaToRef(bodySegment) {
2
+ const schemaRefBodySegment = bodySegment;
3
+ return {
4
+ $ref: `#/components/schemas/${schemaRefBodySegment.$schema.replace(/^#\/components\/schemas\//, '')}`,
5
+ };
6
+ }
@@ -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
  *
@@ -0,0 +1,3 @@
1
+ import { OpenapiSchemaExpressionRef } from '@rvoh/dream';
2
+ import { OpenapiBodySegment } from '../body-segment.js';
3
+ export default function schemaToRef(bodySegment: OpenapiBodySegment): OpenapiSchemaExpressionRef;
@@ -1,5 +1,6 @@
1
- import { DreamSerializer, OpenapiSchemaBody, OpenapiSchemaBodyShorthand, OpenapiSchemaObject, OpenapiShorthandPrimitiveTypes } from '@rvoh/dream';
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';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic",
4
4
  "description": "Typescript web framework",
5
- "version": "0.31.1",
5
+ "version": "0.31.2",
6
6
  "author": "RVOHealth",
7
7
  "repository": {
8
8
  "type": "git",