Skip to content

fix: invalid enum on container schemas in OpenAPI generation#227

Merged
EnriqueL8 merged 1 commit into
mainfrom
fix-enum-on-array-schema
Jul 1, 2026
Merged

fix: invalid enum on container schemas in OpenAPI generation#227
EnriqueL8 merged 1 commit into
mainfrom
fix-enum-on-array-schema

Conversation

@EnriqueL8

Copy link
Copy Markdown
Contributor

The ffenum tag handler applied schema.Enum unconditionally. For container fields ([]FFEnum, map[string]FFEnum) the openapi3gen library invokes the schema customizer with the same field tag for both the container schema and its element schema, so the enum was stamped on the "array"/"object" container node as well as the string leaf. An enum on a type:array or type:object node is invalid OpenAPI and is rejected by strict SDK generators (kin-openapi's own Validate() does not catch it).

The ffenum tag handler applied schema.Enum unconditionally. For container
fields ([]FFEnum, map[string]FFEnum) the openapi3gen library invokes the
schema customizer with the same field tag for both the container schema and
its element schema, so the enum was stamped on the "array"/"object" container
node as well as the string leaf. An enum on a type:array or type:object node
is invalid OpenAPI and is rejected by strict SDK generators (kin-openapi's own
Validate() does not catch it).

Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>

@peterbroadhurst peterbroadhurst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EnriqueL8 - this looks very clear to me

@onelapahead onelapahead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an openapi linter utility ?

@EnriqueL8 EnriqueL8 marked this pull request as ready for review June 30, 2026 15:42
@EnriqueL8 EnriqueL8 requested a review from a team as a code owner June 30, 2026 15:42
@EnriqueL8

Copy link
Copy Markdown
Contributor Author

We can add an openapi linter in a following PR, looked into different package vaccuum could be one https://github.com/daveshanley/vacuum

@EnriqueL8 EnriqueL8 merged commit b91a1eb into main Jul 1, 2026
3 checks passed
@EnriqueL8 EnriqueL8 deleted the fix-enum-on-array-schema branch July 1, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants