@skmtc/core 0.41.0 → 0.42.0

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.
Files changed (53) hide show
  1. package/esm/context/ParseContext.d.ts +17 -0
  2. package/esm/context/ParseContext.js +50 -28
  3. package/esm/context/generateTypes.d.ts +10 -10
  4. package/esm/context/tryParseAt.d.ts +3 -3
  5. package/esm/context/tryParseAt.js +4 -4
  6. package/esm/helpers/refFns.d.ts +3 -1
  7. package/esm/helpers/refFns.js +5 -2
  8. package/esm/oas/operation/Operation.d.ts +1 -4
  9. package/esm/oas/operation/Operation.js +5 -6
  10. package/esm/oas/operation/toEffectiveParameters.d.ts +0 -8
  11. package/esm/oas/operation/toEffectiveParameters.js +3 -32
  12. package/esm/oas/ref/DanglingRefError.d.ts +3 -3
  13. package/esm/oas/ref/DanglingRefError.js +3 -3
  14. package/esm/oas/ref/Ref.d.ts +1 -1
  15. package/esm/oas/ref/Ref.js +1 -1
  16. package/esm/oas/union/Union.d.ts +1 -1
  17. package/esm/oas/union/Union.js +1 -1
  18. package/esm/oas/webhook/Webhook.js +4 -2
  19. package/esm/parse/v3-0/_merge-all-of/merge-union.js +9 -1
  20. package/esm/parse/v3-0/schema/toSchemasV3.js +6 -3
  21. package/esm/parse/v3-1/_merge-all-of/merge-union.js +16 -4
  22. package/esm/parse/v3-1/schema/toSchemasV3.js +6 -3
  23. package/esm/parse/v3-2/_merge-all-of/merge-union.js +16 -4
  24. package/esm/parse/v3-2/schema/toSchemasV3.js +6 -3
  25. package/esm/types/Settings.d.ts +19 -8
  26. package/esm/types/Settings.js +18 -1
  27. package/package.json +1 -1
  28. package/script/context/ParseContext.d.ts +17 -0
  29. package/script/context/ParseContext.js +50 -28
  30. package/script/context/generateTypes.d.ts +10 -10
  31. package/script/context/tryParseAt.d.ts +3 -3
  32. package/script/context/tryParseAt.js +4 -4
  33. package/script/helpers/refFns.d.ts +3 -1
  34. package/script/helpers/refFns.js +5 -2
  35. package/script/oas/operation/Operation.d.ts +1 -4
  36. package/script/oas/operation/Operation.js +4 -5
  37. package/script/oas/operation/toEffectiveParameters.d.ts +0 -8
  38. package/script/oas/operation/toEffectiveParameters.js +4 -34
  39. package/script/oas/ref/DanglingRefError.d.ts +3 -3
  40. package/script/oas/ref/DanglingRefError.js +3 -3
  41. package/script/oas/ref/Ref.d.ts +1 -1
  42. package/script/oas/ref/Ref.js +1 -1
  43. package/script/oas/union/Union.d.ts +1 -1
  44. package/script/oas/union/Union.js +1 -1
  45. package/script/oas/webhook/Webhook.js +3 -1
  46. package/script/parse/v3-0/_merge-all-of/merge-union.js +9 -1
  47. package/script/parse/v3-0/schema/toSchemasV3.js +6 -3
  48. package/script/parse/v3-1/_merge-all-of/merge-union.js +16 -4
  49. package/script/parse/v3-1/schema/toSchemasV3.js +6 -3
  50. package/script/parse/v3-2/_merge-all-of/merge-union.js +16 -4
  51. package/script/parse/v3-2/schema/toSchemasV3.js +6 -3
  52. package/script/types/Settings.d.ts +19 -8
  53. package/script/types/Settings.js +19 -2
@@ -52,6 +52,11 @@ type GqlProtocolState = {
52
52
  options: GqlParseOptions;
53
53
  };
54
54
  type ProtocolState = OasProtocolState | GqlProtocolState;
55
+ type ToDanglingAllOfMemberArgs = {
56
+ $ref: string;
57
+ /** The schema that holds the `allOf`. */
58
+ stackTrail: StackTrail;
59
+ };
55
60
  type ConstructorArgs = {
56
61
  input: SkmtcDocumentInput;
57
62
  logger: Logger;
@@ -166,6 +171,18 @@ export declare class ParseContext {
166
171
  * resolve it there.
167
172
  */
168
173
  registerOasRef<T extends OasRefData['refType']>(consumer: StackTrail, ref: OasRef<T>): void;
174
+ /**
175
+ * What a merge reads in place of a `$ref` that names nothing: an `allOf`
176
+ * member, or in a `oneOf` or `anyOf`, a member's own `allOf` member or a
177
+ * member merged with the keywords beside the union. When
178
+ * `system.danglingRefs` lists `allOfMember`, it is `{}`, which
179
+ * adds nothing to the merge (`A & unknown` is `A`), and a `DANGLING_REF`
180
+ * warning at `stackTrail`: the model has no properties from that member.
181
+ * Otherwise it throws `DanglingRefError`, and what holds the `allOf` is
182
+ * removed. It is separate from `schema`: here core decides, at parse, and
183
+ * the generator never sees the member.
184
+ */
185
+ toDanglingAllOfMember({ $ref, stackTrail }: ToDanglingAllOfMemberArgs): OpenAPIV3.SchemaObject;
169
186
  /**
170
187
  * Register an error against a ref key — typically called when the
171
188
  * target of a `$ref` (or type reference) fails to parse. `undefined`
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_toRawComponentParameter, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_logDanglingRef;
12
+ var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_toRawComponentParameter, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_removeHolder;
13
13
  /**
14
14
  * Unified parse context for both OAS and GraphQL inputs.
15
15
  *
@@ -390,6 +390,31 @@ export class ParseContext {
390
390
  this.registerRef(consumer, toRefKey(ref.$ref));
391
391
  __classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref });
392
392
  }
393
+ /**
394
+ * What a merge reads in place of a `$ref` that names nothing: an `allOf`
395
+ * member, or in a `oneOf` or `anyOf`, a member's own `allOf` member or a
396
+ * member merged with the keywords beside the union. When
397
+ * `system.danglingRefs` lists `allOfMember`, it is `{}`, which
398
+ * adds nothing to the merge (`A & unknown` is `A`), and a `DANGLING_REF`
399
+ * warning at `stackTrail`: the model has no properties from that member.
400
+ * Otherwise it throws `DanglingRefError`, and what holds the `allOf` is
401
+ * removed. It is separate from `schema`: here core decides, at parse, and
402
+ * the generator never sees the member.
403
+ */
404
+ toDanglingAllOfMember({ $ref, stackTrail }) {
405
+ const error = new DanglingRefError($ref);
406
+ if (!this.system.danglingRefs?.includes('allOfMember')) {
407
+ throw error;
408
+ }
409
+ this.logIssueNoKey({
410
+ level: 'warning',
411
+ message: `${error.message}. It is left out of the allOf merge (system.danglingRefs lists 'allOfMember').`,
412
+ parent: { $ref },
413
+ stackTrail,
414
+ type: 'DANGLING_REF'
415
+ });
416
+ return {};
417
+ }
393
418
  /**
394
419
  * Register an error against a ref key — typically called when the
395
420
  * target of a `$ref` (or type reference) fails to parse. `undefined`
@@ -663,48 +688,45 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
663
688
  ref.resolveOnce();
664
689
  }
665
690
  catch (error) {
666
- if (DanglingRefError.is(error)) {
667
- __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDanglingRef).call(this, { consumer, ref, error });
691
+ if (!DanglingRefError.is(error)) {
692
+ const message = error instanceof Error ? error.message : String(error);
693
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
694
+ consumer,
695
+ ref,
696
+ error,
697
+ type: 'REF_TYPE_MISMATCH',
698
+ message: `${message}, so what holds it is removed.`
699
+ });
668
700
  }
669
- else {
701
+ else if (this.system.danglingRefs?.includes(ref.refType)) {
670
702
  this.logIssueNoKey({
671
703
  level: 'warning',
672
- message: `${error instanceof Error ? error.message : String(error)}. It is kept, and resolving it throws.`,
704
+ message: `${error.message}. It is kept (system.danglingRefs lists '${ref.refType}'), and resolving it throws DanglingRefError.`,
673
705
  parent: { $ref: ref.$ref },
674
706
  stackTrail: consumer,
675
- type: 'REF_TYPE_MISMATCH'
707
+ type: 'DANGLING_REF'
708
+ });
709
+ }
710
+ else {
711
+ __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
712
+ consumer,
713
+ ref,
714
+ error,
715
+ type: 'DANGLING_REF',
716
+ message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in system.danglingRefs.`
676
717
  });
677
718
  }
678
719
  }
679
720
  });
680
- }, _ParseContext_logDanglingRef = function _ParseContext_logDanglingRef({ consumer, ref, error }) {
681
- const exampleOrLink = ref.refType === 'example' || ref.refType === 'link';
682
- if (exampleOrLink || this.system.danglingRefs === 'keep') {
683
- this.logIssueNoKey({
684
- level: 'warning',
685
- message: exampleOrLink
686
- ? `${error.message}. It is kept, as a ref to an example or a link is in both system.danglingRefs modes, and resolving it throws DanglingRefError.`
687
- : `${error.message}. It is kept (system.danglingRefs is keep), and resolving it throws DanglingRefError.`,
688
- parent: { $ref: ref.$ref },
689
- stackTrail: consumer,
690
- type: 'DANGLING_REF'
691
- });
692
- return;
693
- }
694
- // An error inside a component removes that component, and what uses it
695
- // (`removeErroredItems`).
721
+ }, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, error, type, message }) {
696
722
  this.logIssueNoKey({
697
723
  level: 'error',
698
- message: `${error.message}, so what holds it is removed (system.danglingRefs is strict).`,
724
+ message,
699
725
  cause: error,
700
726
  parent: { $ref: ref.$ref },
701
727
  stackTrail: consumer,
702
- type: 'DANGLING_REF'
728
+ type
703
729
  });
704
- // What holds the ref outside the components (an operation, a webhook, a
705
- // path-level parameter) is removed here. Its own location has the
706
- // DANGLING_REF already; an operation that a path-level parameter applies
707
- // to gets an INVALID_DEPENDENCY_REF.
708
730
  const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
709
731
  if (documentTrail.toStackRef() !== undefined) {
710
732
  return;
@@ -186,18 +186,18 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
186
186
  * One for each schema.
187
187
  *
188
188
  * `DANGLING_REF` — a `$ref` names nothing in the document. One for each
189
- * place the `$ref` is written. An `error` under `system.danglingRefs:
190
- * strict` (the default): what holds the ref is removed, and each item that
191
- * uses it gets an `INVALID_DEPENDENCY_REF`. A `warning` under `keep`: the
192
- * ref stays, and resolving it throws `DanglingRefError`. A ref to an example
193
- * or a link is a `warning` in both modes. A ref that core resolves while it
194
- * parses (an `allOf` member that it merges) is an `error` in both modes, at
195
- * the item that holds it.
189
+ * place the `$ref` is written. A `warning` when `system.danglingRefs` lists
190
+ * the `$ref`'s kind: the ref stays, and resolving it throws
191
+ * `DanglingRefError`; with `allOfMember` listed, a `$ref` that core merges
192
+ * (in an `allOf`, or in a `oneOf` or `anyOf` member) is left out of the
193
+ * merge. Otherwise (the default lists none)
194
+ * an `error`: what holds the ref is removed, and each item that uses it gets
195
+ * an `INVALID_DEPENDENCY_REF`.
196
196
  *
197
- * `REF_TYPE_MISMATCH` (`warning`) — a `$ref` names a component of the wrong
197
+ * `REF_TYPE_MISMATCH` (`error`) — a `$ref` names a component of the wrong
198
198
  * kind, such as a request body that is a `$ref` to
199
- * `#/components/schemas/Pet`. One for each place the `$ref` is written. The
200
- * ref stays, and resolving it throws.
199
+ * `#/components/schemas/Pet`. One for each place the `$ref` is written. What
200
+ * holds the ref is removed; `system.danglingRefs` does not apply.
201
201
  *
202
202
  * `RUN_FAILED` (`error`) — the run itself failed outside the per-item
203
203
  * catches. Its `location` names the entry and phase, for example
@@ -61,9 +61,9 @@ export type TryParseAtArgs<T> = {
61
61
  *
62
62
  * - logs a `level: 'error'` issue at the child location with the
63
63
  * given `type` and the thrown value as `cause`. A `DanglingRefError`
64
- * is logged as `DANGLING_REF`: core resolved a ref while it parsed (an
65
- * `allOf` member it merges, say), so the ref cannot be kept, whatever
66
- * `system.danglingRefs` is
64
+ * is logged as `DANGLING_REF`: core resolved a ref while it parsed (one
65
+ * it merges, in an `allOf` or a `oneOf` or `anyOf` member, when
66
+ * `system.danglingRefs` does not list `allOfMember`)
67
67
  * - registers a ref error if `refKey` is provided
68
68
  * - returns `undefined`
69
69
  *
@@ -25,9 +25,9 @@ import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
25
25
  *
26
26
  * - logs a `level: 'error'` issue at the child location with the
27
27
  * given `type` and the thrown value as `cause`. A `DanglingRefError`
28
- * is logged as `DANGLING_REF`: core resolved a ref while it parsed (an
29
- * `allOf` member it merges, say), so the ref cannot be kept, whatever
30
- * `system.danglingRefs` is
28
+ * is logged as `DANGLING_REF`: core resolved a ref while it parsed (one
29
+ * it merges, in an `allOf` or a `oneOf` or `anyOf` member, when
30
+ * `system.danglingRefs` does not list `allOfMember`)
31
31
  * - registers a ref error if `refKey` is provided
32
32
  * - returns `undefined`
33
33
  *
@@ -49,7 +49,7 @@ export const tryParseAt = ({ stackTrail, key, context, type, parent, refKey, fn
49
49
  stackTrail: childStack,
50
50
  parent,
51
51
  message: dangling
52
- ? `${normalized.message}. Core resolves it while it parses, so what holds it is removed whatever system.danglingRefs is.`
52
+ ? `${normalized.message}. Core resolves it while it parses, so what holds it is removed.`
53
53
  : normalized.message,
54
54
  cause: normalized,
55
55
  type: dangling ? 'DANGLING_REF' : type
@@ -171,5 +171,7 @@ export declare const isRef: (value: unknown) => value is Ref;
171
171
  * }
172
172
  * ```
173
173
  */
174
- export declare const toGetRef: (oasDocument: OpenAPIV3.Document) => ({ $ref }: ReferenceObject) => OpenAPIV3.SchemaObject;
174
+ export declare const toGetRef: (oasDocument: OpenAPIV3.Document, onDangling?: OnDangling) => ({ $ref }: ReferenceObject) => OpenAPIV3.SchemaObject;
175
+ /** What a resolver reads in place of a `$ref` that names nothing; it may throw. */
176
+ type OnDangling = ($ref: string) => OpenAPIV3.SchemaObject;
175
177
  export {};
@@ -188,14 +188,17 @@ export const isRef = (value) => {
188
188
  * }
189
189
  * ```
190
190
  */
191
- export const toGetRef = (oasDocument) => ({ $ref }) => {
191
+ export const toGetRef = (oasDocument, onDangling) => ({ $ref }) => {
192
192
  const refName = toRefName($ref);
193
193
  const item = oasDocument.components?.schemas?.[refName];
194
194
  if (isRef(item)) {
195
- return toGetRef(oasDocument)(item);
195
+ return toGetRef(oasDocument, onDangling)(item);
196
196
  }
197
197
  if (item) {
198
198
  return item;
199
199
  }
200
+ if (onDangling) {
201
+ return onDangling($ref);
202
+ }
200
203
  throw new DanglingRefError($ref);
201
204
  };
@@ -151,10 +151,7 @@ export declare class OasOperation extends OasBase {
151
151
  *
152
152
  * As OpenAPI defines them: the path item's parameters apply to each of its
153
153
  * operations, and an operation's own parameter with the same name and
154
- * location replaces the path item's. The path item's come first. A
155
- * reference that names nothing (kept under `system.danglingRefs: keep`) is
156
- * left out: it has no name or location, and the parser logged a
157
- * `DANGLING_REF` warning for it.
154
+ * location replaces the path item's. The path item's come first.
158
155
  *
159
156
  * @param filter - only include parameters from specified locations
160
157
  * @returns
@@ -3,7 +3,7 @@ import { traverseSchema } from '../schemaPath/traverseSchema.js';
3
3
  import { OasObject } from '../object/Object.js';
4
4
  import { toPrimaryResponseCode } from '../response/toPrimaryResponseCode.js';
5
5
  import { OasBase } from '../../types/OasBase.js';
6
- import { toEffectiveParameters, toResolvedParameters } from './toEffectiveParameters.js';
6
+ import { toEffectiveParameters } from './toEffectiveParameters.js';
7
7
  export class OasOperation extends OasBase {
8
8
  /**
9
9
  * Creates a new OasOperation instance from operation field data.
@@ -223,16 +223,15 @@ export class OasOperation extends OasBase {
223
223
  *
224
224
  * As OpenAPI defines them: the path item's parameters apply to each of its
225
225
  * operations, and an operation's own parameter with the same name and
226
- * location replaces the path item's. The path item's come first. A
227
- * reference that names nothing (kept under `system.danglingRefs: keep`) is
228
- * left out: it has no name or location, and the parser logged a
229
- * `DANGLING_REF` warning for it.
226
+ * location replaces the path item's. The path item's come first.
230
227
  *
231
228
  * @param filter - only include parameters from specified locations
232
229
  * @returns
233
230
  */
234
231
  toParams(filter) {
235
- return toResolvedParameters(toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })).filter(param => (filter?.length ? filter.includes(param.location) : true));
232
+ return toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })
233
+ .map(param => param.resolve())
234
+ .filter(param => (filter?.length ? filter.includes(param.location) : true));
236
235
  }
237
236
  /**
238
237
  * Creates an OAS object representation of operation parameters.
@@ -11,14 +11,6 @@ type ToEffectiveParametersArgs = {
11
11
  * The parameters that apply to an operation or webhook, as OpenAPI defines
12
12
  * them: the path item's first, then its own. An own parameter with the same
13
13
  * name and location replaces the path item's. References stay references.
14
- * A reference that names nothing (kept under `system.danglingRefs: keep`)
15
- * has no name or location, so it replaces nothing and nothing replaces it.
16
14
  */
17
15
  export declare const toEffectiveParameters: ({ own, shared }: ToEffectiveParametersArgs) => Parameter[];
18
- /**
19
- * Resolves each parameter. A reference that names nothing is left out: it
20
- * has no name or location to render, and the parser logged a `DANGLING_REF`
21
- * warning for it.
22
- */
23
- export declare const toResolvedParameters: (parameters: Parameter[]) => OasParameter[];
24
16
  export {};
@@ -1,42 +1,13 @@
1
- import { DanglingRefError } from '../ref/DanglingRefError.js';
2
1
  /**
3
2
  * The parameters that apply to an operation or webhook, as OpenAPI defines
4
3
  * them: the path item's first, then its own. An own parameter with the same
5
4
  * name and location replaces the path item's. References stay references.
6
- * A reference that names nothing (kept under `system.danglingRefs: keep`)
7
- * has no name or location, so it replaces nothing and nothing replaces it.
8
5
  */
9
6
  export const toEffectiveParameters = ({ own = [], shared = [] }) => {
10
7
  const ownKeys = new Set(own.map(toParameterKey));
11
- return [
12
- ...shared.filter(parameter => {
13
- const key = toParameterKey(parameter);
14
- return key === undefined || !ownKeys.has(key);
15
- }),
16
- ...own
17
- ];
8
+ return [...shared.filter(parameter => !ownKeys.has(toParameterKey(parameter))), ...own];
18
9
  };
19
- /**
20
- * Resolves each parameter. A reference that names nothing is left out: it
21
- * has no name or location to render, and the parser logged a `DANGLING_REF`
22
- * warning for it.
23
- */
24
- export const toResolvedParameters = (parameters) => parameters.flatMap(parameter => {
25
- const resolved = toResolvedParameter(parameter);
26
- return resolved === undefined ? [] : [resolved];
27
- });
28
10
  const toParameterKey = (parameter) => {
29
- const resolved = toResolvedParameter(parameter);
30
- return resolved === undefined ? undefined : `${resolved.location}:${resolved.name}`;
31
- };
32
- const toResolvedParameter = (parameter) => {
33
- try {
34
- return parameter.resolve();
35
- }
36
- catch (error) {
37
- if (DanglingRefError.is(error)) {
38
- return undefined;
39
- }
40
- throw error;
41
- }
11
+ const { name, location } = parameter.resolve();
12
+ return `${location}:${name}`;
42
13
  };
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Thrown when a reference that names nothing in the document is resolved.
3
3
  *
4
- * Under `client.json` `system.danglingRefs: strict` (the default) the parser
5
- * removes what holds such a reference, so a generator never meets one. Under
6
- * `keep` the reference stays, and a generator that resolves it can catch
4
+ * By default the parser removes what holds such a reference, so a generator
5
+ * never meets one. When `client.json` `system.danglingRefs` lists the
6
+ * reference's kind, it stays, and a generator that resolves it can catch
7
7
  * this error and render something else in its place. Test for it with
8
8
  * {@link DanglingRefError.is}, not `instanceof`.
9
9
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Thrown when a reference that names nothing in the document is resolved.
3
3
  *
4
- * Under `client.json` `system.danglingRefs: strict` (the default) the parser
5
- * removes what holds such a reference, so a generator never meets one. Under
6
- * `keep` the reference stays, and a generator that resolves it can catch
4
+ * By default the parser removes what holds such a reference, so a generator
5
+ * never meets one. When `client.json` `system.danglingRefs` lists the
6
+ * reference's kind, it stays, and a generator that resolves it can catch
7
7
  * this error and render something else in its place. Test for it with
8
8
  * {@link DanglingRefError.is}, not `instanceof`.
9
9
  */
@@ -233,7 +233,7 @@ export declare class OasRef<T extends OasRefData['refType']> extends OasBase {
233
233
  *
234
234
  * @returns Either the resolved component or another reference in the chain
235
235
  * @throws {DanglingRefError} when the reference names nothing in the
236
- * document (kept under `client.json` `system.danglingRefs: keep`),
236
+ * document (kept when `client.json` `system.danglingRefs` lists its kind),
237
237
  * including a `$ref` with no name, such as `#/components/schemas/`
238
238
  * @throws Error when it names a component of another kind, such as a
239
239
  * `requestBody` ref to `#/components/schemas/…`
@@ -459,7 +459,7 @@ export class OasRef extends OasBase {
459
459
  *
460
460
  * @returns Either the resolved component or another reference in the chain
461
461
  * @throws {DanglingRefError} when the reference names nothing in the
462
- * document (kept under `client.json` `system.danglingRefs: keep`),
462
+ * document (kept when `client.json` `system.danglingRefs` lists its kind),
463
463
  * including a `$ref` with no name, such as `#/components/schemas/`
464
464
  * @throws Error when it names a component of another kind, such as a
465
465
  * `requestBody` ref to `#/components/schemas/…`
@@ -217,7 +217,7 @@ export declare class OasUnion extends OasBase {
217
217
  * property, and that allows only string literals for it. No value may
218
218
  * belong to two members. A member that is a union, or anything other than
219
219
  * an object, makes it `false`, as does a reference on the way that names
220
- * nothing in the document (kept under `system.danglingRefs: keep`).
220
+ * nothing in the document (kept when `system.danglingRefs` lists `schema`).
221
221
  *
222
222
  * It reads the schemas only. A generator may refuse more: one that leaves
223
223
  * out `readOnly` properties cannot discriminate on one.
@@ -285,7 +285,7 @@ export class OasUnion extends OasBase {
285
285
  * property, and that allows only string literals for it. No value may
286
286
  * belong to two members. A member that is a union, or anything other than
287
287
  * an object, makes it `false`, as does a reference on the way that names
288
- * nothing in the document (kept under `system.danglingRefs: keep`).
288
+ * nothing in the document (kept when `system.danglingRefs` lists `schema`).
289
289
  *
290
290
  * It reads the schemas only. A generator may refuse more: one that leaves
291
291
  * out `readOnly` properties cannot discriminate on one.
@@ -1,7 +1,7 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  import { toPrimaryResponseCode } from '../response/toPrimaryResponseCode.js';
3
3
  import { OasBase } from '../../types/OasBase.js';
4
- import { toEffectiveParameters, toResolvedParameters } from '../operation/toEffectiveParameters.js';
4
+ import { toEffectiveParameters } from '../operation/toEffectiveParameters.js';
5
5
  /**
6
6
  * Represents an OpenAPI 3.1 webhook — a third OAS subject, peer to
7
7
  * {@link OasOperation} and the schema/model subjects.
@@ -173,7 +173,9 @@ export class OasWebhook extends OasBase {
173
173
  * parameters carry the same shape, only their direction is inbound.
174
174
  */
175
175
  toParams(filter) {
176
- return toResolvedParameters(toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })).filter(param => (filter?.length ? filter.includes(param.location) : true));
176
+ return toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })
177
+ .map(param => param.resolve())
178
+ .filter(param => (filter?.length ? filter.includes(param.location) : true));
177
179
  }
178
180
  /**
179
181
  * The status code of the primary acknowledgement response — the lowest 2xx
@@ -2,6 +2,7 @@ import { decomposeUnion } from './decompose-union.js';
2
2
  import { mergeSchemasOrRefs } from './merge.js';
3
3
  import { crossProduct } from './cross-product.js';
4
4
  import { isRef } from '../../../helpers/refFns.js';
5
+ import { DanglingRefError } from '../../../oas/ref/DanglingRefError.js';
5
6
  export const mergeUnion = ({ schema, getRef, system, groupType }) => {
6
7
  const { beforeExcluded, decomposed, afterExcluded } = decomposeUnion({ schema, groupType });
7
8
  // if (decomposed.length === 1) {
@@ -49,13 +50,20 @@ export const toOwnSystem = (system) => ({
49
50
  * ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
50
51
  * cross product with no pair that merges fails its pair: the outer pass then
51
52
  * leaves the pair out, or lets the later member win.
53
+ *
54
+ * A `$ref` that names nothing is not a contradiction, so its pair is not left
55
+ * out for it: the `DanglingRefError` is thrown on, and `system.danglingRefs`
56
+ * decides (`allOfMember`).
52
57
  */
53
58
  const mergePairs = ({ pairs, merge, system }) => {
54
59
  const mergeEach = (pairSystem) => pairs.flatMap(pair => {
55
60
  try {
56
61
  return [merge(pair, pairSystem)];
57
62
  }
58
- catch (_error) {
63
+ catch (error) {
64
+ if (DanglingRefError.is(error)) {
65
+ throw error;
66
+ }
59
67
  return [];
60
68
  }
61
69
  });
@@ -177,7 +177,7 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
177
177
  const system = toAllOfSystem(context);
178
178
  const merged = mergeIntersection({
179
179
  schema,
180
- getRef: toGetRef(context.documentObject),
180
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
181
181
  system
182
182
  });
183
183
  logAllOfContradictions({ system, stackTrail, parent: schema, context });
@@ -191,7 +191,9 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
191
191
  const merged = mergeUnion({
192
192
  // A null member makes the union nullable: `oneOf: [$ref, null]` is a nullable reference.
193
193
  schema: withoutNullMembers(schema, 'oneOf'),
194
- getRef: toGetRef(context.documentObject),
194
+ // A member's own `allOf`, or a member merged with the keywords beside
195
+ // the `oneOf`, is merged here, so it follows `allOfMember` too.
196
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
195
197
  system,
196
198
  groupType: 'oneOf'
197
199
  });
@@ -259,7 +261,8 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
259
261
  const system = toAllOfSystem(context);
260
262
  const merged = mergeUnion({
261
263
  schema: withoutNullMembers(schema, 'anyOf'),
262
- getRef: toGetRef(context.documentObject),
264
+ // As for `oneOf`: what is merged here follows `allOfMember`.
265
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
263
266
  system,
264
267
  groupType: 'anyOf'
265
268
  });
@@ -2,6 +2,7 @@ import { decomposeUnion, isUnionLevelKey } from './decompose-union.js';
2
2
  import { mergeSchemasOrRefs } from './merge.js';
3
3
  import { crossProduct } from './cross-product.js';
4
4
  import { isRef } from '../../../helpers/refFns.js';
5
+ import { DanglingRefError } from '../../../oas/ref/DanglingRefError.js';
5
6
  export const mergeUnion = ({ schema, getRef, normalize, system, groupType }) => {
6
7
  const { beforeExcluded, decomposed, afterExcluded } = decomposeUnion({ schema, groupType });
7
8
  // if (decomposed.length === 1) {
@@ -56,13 +57,20 @@ export const toOwnSystem = (system) => ({
56
57
  * ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
57
58
  * cross product with no pair that merges fails its pair: the outer pass then
58
59
  * leaves the pair out, or lets the later member win.
60
+ *
61
+ * A `$ref` that names nothing is not a contradiction, so its pair is not left
62
+ * out for it: the `DanglingRefError` is thrown on, and `system.danglingRefs`
63
+ * decides (`allOfMember`).
59
64
  */
60
65
  const mergePairs = ({ pairs, merge, system }) => {
61
66
  const mergeEach = (pairSystem) => pairs.flatMap(pair => {
62
67
  try {
63
68
  return [merge(pair, pairSystem)];
64
69
  }
65
- catch (_error) {
70
+ catch (error) {
71
+ if (DanglingRefError.is(error)) {
72
+ throw error;
73
+ }
66
74
  return [];
67
75
  }
68
76
  });
@@ -114,8 +122,9 @@ export const mergeCrossProduct = ({ first, second, getRef, normalize, system, gr
114
122
  * to a `oneOf` with `minLength` beside it. Union-level keys (`nullable`,
115
123
  * `description`, …) are not merged in, and a `$ref` member is returned
116
124
  * unchanged. A member that conflicts with the
117
- * siblings is dropped, as in the cross product. A schema with no group is
118
- * its own only member and is returned unchanged.
125
+ * siblings is dropped, as in the cross product, but not one with a `$ref`
126
+ * that names nothing: that is no conflict. A schema with no group is its own
127
+ * only member and is returned unchanged.
119
128
  */
120
129
  const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupType }) => {
121
130
  if (!Array.isArray(schema[groupType])) {
@@ -135,7 +144,10 @@ const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupTy
135
144
  try {
136
145
  return mergeSchemasOrRefs({ first: siblingSchema, second: member, getRef, normalize, system });
137
146
  }
138
- catch (_error) {
147
+ catch (error) {
148
+ if (DanglingRefError.is(error)) {
149
+ throw error;
150
+ }
139
151
  return undefined;
140
152
  }
141
153
  })
@@ -229,7 +229,7 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
229
229
  const system = toAllOfSystem(context);
230
230
  const merged = mergeIntersection({
231
231
  schema: wrapper,
232
- getRef: toGetRef(context.documentObject),
232
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
233
233
  normalize: normalizeMergeMember,
234
234
  system
235
235
  });
@@ -261,7 +261,9 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
261
261
  const system = toAllOfSystem(context);
262
262
  const merged = mergeUnion({
263
263
  schema: withoutNull,
264
- getRef: toGetRef(context.documentObject),
264
+ // A member's own `allOf`, or a member merged with the keywords beside
265
+ // the `oneOf`, is merged here, so it follows `allOfMember` too.
266
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
265
267
  normalize: normalizeMergeMember,
266
268
  system,
267
269
  groupType: 'oneOf'
@@ -342,7 +344,8 @@ export const toSchemaV3 = ({ schema, stackTrail, context }) => {
342
344
  const system = toAllOfSystem(context);
343
345
  const merged = mergeUnion({
344
346
  schema: withoutNull,
345
- getRef: toGetRef(context.documentObject),
347
+ // As for `oneOf`: what is merged here follows `allOfMember`.
348
+ getRef: toGetRef(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
346
349
  normalize: normalizeMergeMember,
347
350
  system,
348
351
  groupType: 'anyOf'