Skip to content

Commit

Permalink
feat: OpenAPI allow non-nominal cases in enum (#2578)
Browse files Browse the repository at this point in the history
We used to collect the references of the child cases and fail in case we came across a case without a nominal ref. This is not needed to correctly generate the `pneOf` structure in the openapi document, but to include the children to the schemas. After the change, we simply skip cases without a nominal ref when collection children. This allows for schemas like `Enum2(String, Int)` to be turned into `oneOf: [string, int]` correctly. Obviously, there will be no child schemas in this case.
  • Loading branch information
runtologist authored Jan 2, 2024
1 parent badb929 commit be67a7d
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,11 @@ object JsonSchema {
val key =
nominal(c.schema, refType)
.orElse(nominal(c.schema, SchemaStyle.Compact))
.getOrElse(throw new Exception(s"Unsupported enum case schema: ${c.schema}"))
val nested = fromZSchemaMulti(
c.schema,
refType,
)
nested.children + (key -> nested.root)
nested.children ++ key.map(_ -> nested.root)
}
.toMap,
)
Expand Down

0 comments on commit be67a7d

Please sign in to comment.