Openapi gen gives odd result

Cheers! I have an optional of a struct and the resulting openapi yaml looks like

    varName:
      nullable: true
      allOf:
      - $ref: '#/components/schemas/StructTypeName'

I expect
varName:
nullable: true
$ref: ‘#/components/schemas/StructTypeName’

Please fix asap

Hi @Dionysus,

I expect

varName:
  nullable: true
  $ref: '#/components/schemas/StructTypeName'

Yes, that would be great.

Unfortunately, a $ref comes in place of everything else, so it’s impossible to combine a $ref and a nullable property. This is a known issue in the OpenAPI community.

The suggested approach is to use the nullable + allOf approach, which is exactly what we do.

Many openapi client generators support this pattern, and will output the expected nullable struct in their generated client code.