Skip to content

[Bug]: Array schema description leaks into items #5051

@jochenberger

Description

@jochenberger

I have an annotation like this

 @ApiResponse(
      responseCode = "201",
      content = @Content(
              mediaType = MediaType.APPLICATION_JSON_VALUE,
              array =
                  @ArraySchema(
                          arraySchema = @Schema(description = "Array description"),
                      schema =
                          @Schema(
                              description = "Item description",
                              implementation = Item.class
                              )))))
List<Item> doSomething();

The generated schema looks like this:

[
  type:array,
  description: Array description,
  items: [
    $ref:#/components/schemas/Item,
    description:Array description
  ]
]

The array description overrides the item description.

If I remove the implementation = Item.class, I get

[
  type:array,
  description: Array description,
  items: [
    type:string,
    description:Item description
  ]
]

The item description is there, but the type is wrong. IIUC, It should be deduced from the method signature.

If I remove the whole schema = ... part, I get

[
  type:array,
  description: Array description
]

The items section is missing completely. At least the type info should be there.

I remember there were similar issues in the components schema generation. This concerns the API response schemas. I assumed they were using the same logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions