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

Description for array schema is being ignored when generating OpenAPI 3.1

Open jochenberger opened this issue 11 months ago • 2 comments

I have the following Java code:

class Street {
        @ArraySchema(schema = @Schema(implementation = House.class, description = "A house in the street"),
                     arraySchema = @Schema(description = "The houses in the street"))
        public List<House> houses;
}

When generating OpenAPI 3.0, I get

Street:
type: object
properties:
  houses:
    type: array
    description: The houses in the street
    items:
      $ref: "#/components/schemas/House"

The item description is missing, but that's another issue (https://github.com/swagger-api/swagger-core/issues/3900). However, when I generate OpenAPI 3.1, I get

Street:
type: object
properties:
  houses:
    type: array
    items:
      $ref: "#/components/schemas/House"
      description: A house in the street

Now, the item description is there, but the array description is missing.

jochenberger avatar Jan 21 '25 07:01 jochenberger

I have the same problem.

See issue where I described the problem: https://github.com/springdoc/springdoc-openapi/issues/2953

From OpenAPI 3.0:

...
  "components": {
    "schemas": {
          "ClassName": {
            "type": "object",
            "properties": {
              "fieldName1": {
                "type": "string",
                "description": "A text here1."
              },
              "fieldName2": {
                "type": "array",
                "description": "A text here2.",
                "items": {
                  "type": "string"
                }
              }
            }
          }
...

And in OpenAPI 3.1:

...
  "components": {
    "schemas": {
          "ClassName": {
            "type": "object",
            "properties": {
              "fieldName1": {
                "type": "string",
                "description": "A text here1."
              },
              "fieldName2": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
...

seskildsen avatar Mar 28 '25 09:03 seskildsen

Doesn't seem to be fixed in 2.2.31.

jochenberger avatar May 14 '25 07:05 jochenberger

Sill missing in 2.2.34.

jochenberger avatar Jul 28 '25 13:07 jochenberger

#4942 has a failing test but I haven't managed to come up with a fix yet.

jochenberger avatar Jul 30 '25 11:07 jochenberger

#4942 has a potential fix.

jochenberger avatar Aug 26 '25 10:08 jochenberger

title actually has the same issue.

jochenberger avatar Aug 26 '25 12:08 jochenberger

I think that the bug was introduced in 7294019dc203b3995671084fd2b6b51525af1ea8.

jochenberger avatar Aug 26 '25 12:08 jochenberger

@frantuma, can you advise?

jochenberger avatar Aug 26 '25 12:08 jochenberger

Sill an issue in 2.2.37, fix available in #4942

jochenberger avatar Sep 17 '25 06:09 jochenberger

@jochenberger appreciate your effort and input here! The fix will be included in the incoming release version.

djankows avatar Sep 18 '25 15:09 djankows