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

Request body added to GET requests #18

Open
rtehok opened this issue Jul 22, 2022 · 2 comments
Open

Request body added to GET requests #18

rtehok opened this issue Jul 22, 2022 · 2 comments

Comments

@rtehok
Copy link

rtehok commented Jul 22, 2022

Hello,

I have the same issue than https://stackoverflow.com/questions/51372542/swagger-is-adding-additional-body-parameter-for-get-method and https://stackoverflow.com/questions/57202122/swagger-why-is-swagger-creating-a-request-body-field-when-i-have-not-written-a and I cannot find a solution to this issue:

  @GET
  @Path("foo/{id}")
  @Produces(Array(MediaType.APPLICATION_JSON))
  @Operation(summary = "returns something", description = "",
    responses = Array(
      new ApiResponse(responseCode = "200", description = "return",
        content = Array(new Content(schema = new Schema(implementation = classOf[ReturnResponse])))),
      new ApiResponse(responseCode = "500", description = "Internal server error"))
  )
  def getId(@PathParam("id") id: String)(user: User): Route = {

Is it possible to remove the User message added to the request body ?

Thank you !

@pjfanning
Copy link
Owner

This whole thing is trial and error. As the answer to the stackoverflow question suggests, there are better ways to generate OpenAPI specs.

One thing you could try is setting the parameters value in the Operation annotation. This might get swagger to ignore the input params in the method/function.

  @Operation(summary = "Return Hello greeting", description = "Return Hello greeting for named user",
    parameters = Array(new Parameter(name = "name", in = ParameterIn.PATH, description = "user name")),

There are other annotations you could try. See https://docs.swagger.io/swagger-core/v2.2.1/apidocs/io/swagger/v3/oas/annotations/package-summary.html

@rtehok
Copy link
Author

rtehok commented Jul 25, 2022

Ok, I found the solution, that I wrote here.
Thanks for your reply.

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