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

Support GET with body in OpenApiResource endpoints #1813

Closed
okohub opened this issue Aug 24, 2022 · 2 comments
Closed

Support GET with body in OpenApiResource endpoints #1813

okohub opened this issue Aug 24, 2022 · 2 comments

Comments

@okohub
Copy link

okohub commented Aug 24, 2022

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.

@bnasslahsen
Copy link
Contributor

@okohub,

Feel free to propose a PR and link it to this ticket and i will review it.

@okohub
Copy link
Author

okohub commented Aug 24, 2022

@bnasslahsen thanks will take a look 🎈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants