Skip to content

Commit 5442f00

Browse files
chore: update tests
1 parent 91c1b6c commit 5442f00

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

components.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,61 @@ components:
24562456
type: string
24572457
required:
24582458
- b
2459+
# Nested union test schemas - tests that only the winning inner option's
2460+
# unrecognized count is propagated to the parent union
2461+
smartUnionNestedInnerCat:
2462+
type: object
2463+
properties:
2464+
kind:
2465+
type: string
2466+
enum:
2467+
- cat
2468+
x-speakeasy-unknown-values: allow
2469+
name:
2470+
type: string
2471+
required:
2472+
- kind
2473+
- name
2474+
smartUnionNestedInnerDog:
2475+
type: object
2476+
properties:
2477+
kind:
2478+
type: string
2479+
enum:
2480+
- dog
2481+
x-speakeasy-unknown-values: allow
2482+
required:
2483+
- kind
2484+
smartUnionNestedInnerBird:
2485+
type: object
2486+
properties:
2487+
kind:
2488+
type: string
2489+
enum:
2490+
- bird
2491+
x-speakeasy-unknown-values: allow
2492+
required:
2493+
- kind
2494+
smartUnionNestedOuterB:
2495+
type: object
2496+
description: |
2497+
Option B for outer union - has 2 open enum fields.
2498+
Both kind and name are open enums, so parsing unknown values
2499+
will count 2 unrecognized.
2500+
properties:
2501+
kind:
2502+
type: string
2503+
enum:
2504+
- x
2505+
x-speakeasy-unknown-values: allow
2506+
name:
2507+
type: string
2508+
enum:
2509+
- y
2510+
x-speakeasy-unknown-values: allow
2511+
required:
2512+
- kind
2513+
- name
24592514

24602515
responses:
24612516
tokenAuthResponse:

test.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12503,6 +12503,83 @@ paths:
1250312503
- $ref: "components.yaml#/components/schemas/smartUnionEmptyStringObjectB"
1250412504
required:
1250512505
- json
12506+
/smartunion/nestedunion:
12507+
post:
12508+
operationId: smartUnionNestedUnion
12509+
summary: Nested union should only count winning inner option's unrecognized
12510+
description: |
12511+
Test case: nested union count propagation
12512+
Outer union:
12513+
- Option A: { data: InnerUnion } where InnerUnion has 3 options with open enums
12514+
- Option B: { data: { kind: OpenEnum, name: OpenEnum } } has 2 open enum fields
12515+
Inner union (inside Option A):
12516+
- { kind: OpenEnum["cat"], name: string } - 2 fields
12517+
- { kind: OpenEnum["dog"] } - 1 field
12518+
- { kind: OpenEnum["bird"] } - 1 field
12519+
Payload: { data: { kind: "unknown", name: "also_unknown" } }
12520+
12521+
Expected: Option A should win because:
12522+
- Inner union picks the cat variant (has name field), counts 1 unrecognized (kind="unknown")
12523+
- Option B would count 2 unrecognized (both kind and name are unknown enum values)
12524+
- With correct counting: A=1 < B=2, so A wins
12525+
- With buggy counting: A=3 (accumulated from all inner options) > B=2, so B would wrongly win
12526+
servers:
12527+
- url: http://localhost:35456
12528+
tags:
12529+
- unions
12530+
requestBody:
12531+
content:
12532+
application/json:
12533+
schema:
12534+
oneOf:
12535+
- type: object
12536+
title: smartUnionNestedOuterA
12537+
properties:
12538+
data:
12539+
oneOf:
12540+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerCat"
12541+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerDog"
12542+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerBird"
12543+
required:
12544+
- data
12545+
- type: object
12546+
title: smartUnionNestedOuterBWrapper
12547+
properties:
12548+
data:
12549+
$ref: "components.yaml#/components/schemas/smartUnionNestedOuterB"
12550+
required:
12551+
- data
12552+
required: true
12553+
responses:
12554+
"200":
12555+
description: OK
12556+
content:
12557+
application/json:
12558+
schema:
12559+
title: res
12560+
type: object
12561+
properties:
12562+
json:
12563+
oneOf:
12564+
- type: object
12565+
title: smartUnionNestedOuterA
12566+
properties:
12567+
data:
12568+
oneOf:
12569+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerCat"
12570+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerDog"
12571+
- $ref: "components.yaml#/components/schemas/smartUnionNestedInnerBird"
12572+
required:
12573+
- data
12574+
- type: object
12575+
title: smartUnionNestedOuterBWrapper
12576+
properties:
12577+
data:
12578+
$ref: "components.yaml#/components/schemas/smartUnionNestedOuterB"
12579+
required:
12580+
- data
12581+
required:
12582+
- json
1250612583

1250712584
/method/delete:
1250812585
delete:

0 commit comments

Comments
 (0)