Skip to content

No schema is shown for a valid request body with schema component #3037

@ahoehma

Description

@ahoehma

Describe the bug

  • I have a valid open-api schema for my rest-api
  • I noticed that for request bodies the swagger ui shows only a json example but no schema
  • I extracted the open-api json from /v3/api-docs and used it in https://editor.swagger.io/ and there I can see the schemas, please se the following screenshots

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 3.5.3
  • What modules and versions of springdoc-openapi are you using? 2.8.9
  • What is the actual and the expected result using OpenAPI Description (yml or json)? json
  • See the attached open-api-history.json

Here is the part of the definition which shows that the particular schema for the body is references:

open-api-history.json

"/api/v1/history/search" : {
      "post" : {
        "operationId" : "getHistorySearch",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/GetConfigurationHistorySearchPayload"
              }
            }
          },
          "required" : true
        },
        "responses" : {
          "200" : {
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ConfigurationHistoryResult"
                }
              }
            },
            "description" : "OK"
          }
        },
        "security" : [ {
          "basicScheme" : [ ]
        } ],
        "summary" : "Try to get a single configuration-history entry for given search parameters. If a result was returned it contains a configurationId to request the real configuration, see /history/{configurationId}/configuration. The service will return the latest created (createdOn) configuration by default.",
        "tags" : [ "service", "read" ]
      }
    },

Here is the part from my application.yml:

springdoc:
  cache:
    disabled: true
  enable-spring-security: true
  remove-broken-reference-definitions: false
  show-actuator: false
  show-login-endpoint: true
  swagger-ui:
    csrf:
      enabled: true
    deep-linking: true
    display-request-duration: true
    disable-swagger-default-url: true
    filter: service
    operations-sorter: method
    path: /swagger-ui.html
    show-common-extensions: true
    show-extensions: true 
    syntax-highlight:
      activated: true
    tags-sorter: alpha
    try-it-out-enabled: true
  writer-with-default-pretty-printer: true
  writer-with-order-by-keys: true
  api-docs:
    enabled: true
    version: openapi-3-1
    resolve-schema-properties: true

Expected behavior

  • The "Schema" tab is shown next to the "Example value" tab

Screenshots

Working example via https://editor.swagger.io/

Image

Not working example from my local running springboot service

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions