swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Why does Schema(description="foo") change generated openapi enum type to type: object?

Open cswarth opened this issue 1 year ago • 0 comments

An enum property with Schema description generates an incorrect open api yaml specification, with 'allOf' and 'type: object' that should not be there,

@Data
public class ColumnNameListRequest  {
  @Schema(description="foo")
  private DataGranularity granularity;
}

generates,

    ColumnNameListRequest:
      type: object
      properties:
        granularity:
          allOf:
          - $ref: '#/components/schemas/DataGranularity'
          - type: object
            description: foo

but if I remove description="foo" the generated signature looks correct,

@Data
public class ColumnNameListRequest  {
  @Schema(description="foo")
  private DataGranularity granularity;
}

generates,

    ColumnNameListRequest:
      type: object
      properties:
        granularity:
          $ref: '#/components/schemas/DataGranularity'

Why does the generated openapi type depend on whether I supply a "description" or not?

src.zip

cswarth avatar Mar 05 '24 23:03 cswarth