Skip to content

Support GET with body in OpenApiResource endpoints #1813

Closed
@okohub

Description

@okohub

Springdoc version: 1.6.11

As of OAI/OpenAPI-Specification#2117, body in GET-HEAD-DELETE now supported in OAS 3.1.0

Even I set open api version to 3.1 in properties;

 springdoc:
   api-docs:
     version: openapi_3_1

org.springdoc.webmvc.api.OpenApiResource#openapiJson still creates documentation in legacy structure. I would like to see support of "requestBody" in GET, in springdoc codes.

There are 2 blocking logics exist in AbstractRequestService;

  1. org.springdoc.core.AbstractRequestService#isRequestBodyParam (which is blocking GET)

  2. org.springdoc.core.AbstractRequestService.java:308 (which is an if logic for GET)

If I override those logics with copying some of code, replacing RequestService with new custom one, everything works fine :) I can create something like this;

    "/api/tests/getmebody" : {
      "get" : {
        "tags" : [ "Test" ],
        "operationId" : "getMeBody",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/NewRequest"
              }
            }
          },
          "required" : true
        },
        "responses" : {
          "200" : {
            "description" : "OK",
            "content" : {
              "*/*" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Response"
                }
              }
            }
          }
        }
      }
    }

What do you think? Can we improve AbstractRequestService to generate openapi spec correctly?

Thanks.

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