Does SwagGen support references to properties of a schema?
raphaeloliveira opened this issue · comments
Hey @yonaskolb, our backend team recently added on our openapi spec the following entry on schemas:
A new UpdateCardRequest
UpdateCardRequest:
type: object
required:
- nickname
properties:
nickname:
$ref: '#/components/schemas/Card/properties/nickname'
A new property called nickname
under the existing Card
schema.
Card:
type: object
properties:
...
nickname:
type: string
nullable: true
When swaggen generates the code, Card
correctly receives the new nickname
property of type String
. However, the new UpdateCardRequest
object fails to compile due to unknown Nickname type. Apparently having a $ref
to a property (Card/properties/nickname
) does not make Swaggen generate a typealias or a new object. Is my assumption correct?
As a temporary workaround I could make Nickname a new object under schema
and have the nickname
property under Card
reference it. Thoughts?
Referencing a property in a Schema like that is not supported in SwagGen. I didn’t even know it was part of the open api spec.
If nickname is just a string, I would just define it as such in the UpdateCardRequest, thereby duplicating the definition. I don’t think it’s necessary to make it it’s own type