Skip to content

[Bug]: The OAS 3.1 is missing information from the @ArraysSchema.arraySchema #5012

@martin-rais-brcm

Description

@martin-rais-brcm

The OAS 3.1 is missing information from the @ArraysSchema.arraySchema

Description of the problem/issue

We are using the springdoc with the swagger-core dependency. Once we switched from the OpenApi 3.0 to 3.1 some @Schema information defined in the @ArraySchema.arraySchema do not generate into the OpenApi JSON spec. So far, we've found that following properties are not generated:

  • readOnly
  • accessMode
  • examples

There might be more of them.

Affected Version

2.2.40

Earliest version the bug appears in (if known): we found it in 2.2.36.

Steps to Reproduce

Use this POJO model with a collection property, while generating OAS 3.1:

@Getter
@Setter
public final class MyModel {

  @ArraySchema(
      arraySchema = @Schema(
          deprecated = true,
          accessMode = AccessMode.READ_ONLY,
          description = "collection description",
          examples = "John"),
      schema = @Schema(
          description = "item description",
          examples = "Jason"))
  private List<String> names;
}

Expected Behavior

The OAS 3.1 should contain this definition:

"org.example.MyModel": {
  "type": "object",
  "properties": {
    "names": {
      "type": "array",
      "description": "collection description",
      "deprecated" : true,
      "readOnly" : true,
      "examples" : [
        "John"
      ],
      "items": {
        "type": "string",
        "description": "item description",
        "examples": [
          "Jason"
        ]
      }
    }
  }
}

Actual Behavior

Some fields from the arraySchema are missing in the generated model.
See that description attribute is present, while deprecated, examples and readOnly
are missing.

"org.example.MyModel": {
  "type": "object",
  "properties": {
    "names": {
      "type": "array",
      "description": "collection description",
      "items": {
        "type": "string",
        "description": "item description",
        "examples": [
          "Jason"
        ]
      }
    }
  }
}

Logs / Stack Traces

N/A.

Additional Context

Switching springdoc back to version 3.0, and replacing examples with example in the POJO, the missing fields are present in the generated model.

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

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