Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bernhardkern opened this issue Sep 7, 2023 · 0 comments · Fixed by #2403
Closed

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

bernhardkern opened this issue Sep 7, 2023 · 0 comments · Fixed by #2403
Labels
bug Something isn't working

Comments

@bernhardkern
Copy link

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.

@uc4w6c uc4w6c added the bug Something isn't working label Oct 13, 2023
uc4w6c added a commit to uc4w6c/springdoc-openapi that referenced this issue Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants