Skip to content

SchemaProperty.array Schema is ignored in /api-docs or api-docs.yaml #2373

Closed
@bernhardkern

Description

@bernhardkern

Describe the bug

I would like to generate the yaml in 'Expected behavior' but the
SchemaProperty(array = ArraySchema(schema = Schema(implementation = PagedObject::class))
is ignored. The ref $ref: '#/components/schemas/PagedObject' is missing. The refs for Paging and Links are correctly rendered in #/components/schemas and the refs are working.

SchemaProperty items has no type ref to #/components/schemas/PagedObject:

responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                  paging:
                    $ref: '#/components/schemas/Paging'
                  _links:
                    $ref: '#/components/schemas/Links'

modelled like that:

@ApiResponses(
        value = [
            ApiResponse(
                responseCode = "200",
                description = "ok",
                content = [
                    Content(
                        mediaType = MediaType.APPLICATION_JSON_VALUE,
                        schemaProperties = [
                            SchemaProperty(
                                name = "items",
                                array = ArraySchema(
                                    schema = Schema(implementation = PagedObject::class),)
                            ),
                            SchemaProperty(name = "paging", schema = Schema(implementation = Paging::class)),
                            SchemaProperty(name = "_links", schema = Schema(implementation = Links::class)),
                        ],
                    )
                ]
            )
        ]
    )

Expected behaviour in section 'Expected behavior'

To Reproduce

Sample application public: https://github.com/bernhardkern/springdoc-openapi-array-ignored

  • SpringBoot Version: 3.1.3
  • springdoc-openapi-starter-webmvc-ui Version: 2.2.0
  • Run the SampleApplication with ./gradlew bootRun or gradle bootRun, if you have gradle installed
  • Open http://localhost:8083/v3/api-docs.yaml

Expected behavior

If you open /api-docs.yaml there should be

  • a ref to PagedObject
  • a PagedObject in components/schemas
responses:
        "200":
          description: ok
          content:
            application/json:
              schema:
                properties:
                  items:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/PagedObject"
                  paging:
                    $ref: "#/components/schemas/Paging"
                  _links:
                    $ref: "#/components/schemas/_links"

If I can provide any more context to support, please contact me. Thx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions