Closed alephao closed 4 years ago
Hi, I'm confusing with the issue and the merge request.
Why would @alephao expect that the this_property_should_be_optional
property in ObjectHoldingNullableReference
class should be optional in the codegen result? The this_property_should_be_optional
should be removed from required
in OpenAPI definition.
Hi @ymhuang0808, it's because of the nullable: true
property in SomeNullableObject
. I agree it's a bit weird that the object is defining whether itself can be null or not, but that's also part of the specification.
Given the following components:
I would expect ObjectHoldingNullableReference to have an optional
thisPropertyShouldBeOptional
like the example below:But SwagGen currently generates a non-optional property.
Apparently, the
property.schema.metadata
does not contain the correct information ifschema.type
is a reference, and the correct metadata is wrapped insideschema.type
.https://github.com/yonaskolb/SwagGen/blob/a8e170cb045e33e99cfd2d0c578c1db62387d9b0/Sources/SwagGenKit/SwiftFormatter.swift#L228