Skip to content

Commit

Permalink
Fix OpenAPIGen for opt payloads (#3181)
Browse files Browse the repository at this point in the history
  • Loading branch information
987Nabil authored Sep 29, 2024
1 parent 83a24a5 commit 92af675
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,7 @@ object OpenAPIGenSpec extends ZIOSpecDefault {
| {
| "$ref" : "#/components/schemas/Payload"
| }
| ],
| "description" : ""
| ]
| }
| }
| },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ private[openapi] case class SerializableJsonSchema(
if (nullable && schemaType.isDefined)
copy(schemaType = Some(schemaType.get.add("null")))
else if (nullable && oneOf.isDefined)
copy(oneOf = Some(oneOf.get :+ typeNull))
copy(oneOf = Some((oneOf.get :+ typeNull).distinct))
else if (nullable && allOf.isDefined)
SerializableJsonSchema(allOf = Some(Chunk(this, typeNull)))
SerializableJsonSchema(allOf = Some((allOf.get :+ typeNull).distinct))
else if (nullable && anyOf.isDefined)
copy(anyOf = Some(anyOf.get :+ typeNull))
copy(anyOf = Some((anyOf.get :+ typeNull).distinct))
else if (nullable && ref.isDefined)
SerializableJsonSchema(anyOf = Some(Chunk(typeNull, this)))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,10 @@ object OpenAPIGen {
}
case t: Transform[_, _, _] =>
nominal(t.schema, referenceType)
case Schema.Optional(inner, _) =>
nominal(inner, referenceType)
case Schema.Lazy(schema0) =>
nominal(schema0(), referenceType)
case _ => None
}

Expand Down

0 comments on commit 92af675

Please sign in to comment.