Skip to content

CUE allOf flattening drops duplicate property constraints #10710

Description

@weicao

What happened

Parameter schemas generated from intersected CUE definitions use OpenAPI allOf. When dereferenced object branches are flattened with a first-wins property merge, later constraints on the same field are silently discarded.

For example:

#lower: { x: int & >=1 }
#upper: { x: int & <=10 }
#combined: #lower & #upper

The flattened generated schema retains the lower bound but loses the upper bound, so x = 11 is accepted even though CUE rejects it. The same loss can affect nested references and map value schemas.

Expected behavior

The generated schema should remain self-contained while preserving the full intersection. Both the complete schema and flattened parameter-assignment consumer should reject values that violate any branch.

Reproduction

  1. Generate OpenAPI for #combined.
  2. Validate x = 0, x = 5, and x = 11 against the generated schema.
  3. Repeat after FlattenSchema and string-to-integer conversion.

Only x = 5 should pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions