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

DELETE doesn't propagate the body #225

Open
slinkydeveloper opened this issue Jul 24, 2023 · 4 comments · May be fixed by #226
Open

DELETE doesn't propagate the body #225

slinkydeveloper opened this issue Jul 24, 2023 · 4 comments · May be fixed by #226

Comments

@slinkydeveloper
Copy link

The HTTP DELETE method supports a body, as defined in https://www.rfc-editor.org/rfc/rfc7231#section-4.3.5:

A payload within a DELETE request message has no defined semantics;
sending a payload body on a DELETE request might cause some existing
implementations to reject the request.

But the code generator simply ignores it. It should be easy to fix by changing this line of code: https://github.com/cjbooms/fabrikt/blob/master/src/main/kotlin/com/cjbooms/fabrikt/generators/client/OkHttpSimpleClientGenerator.kt#L212

@slinkydeveloper slinkydeveloper linked a pull request Jul 24, 2023 that will close this issue
@slinkydeveloper
Copy link
Author

A proposed PR here: #226

@aderington
Copy link

I've also run into this issue. I was curious if there was an plan to merge the posted PR (or similar). Thank you!

@cjbooms
Copy link
Owner

cjbooms commented Feb 25, 2025

Open to merging a fix. From what i recall, it wasn't clear what that PR was doing, and requests for clarification or tests were ignored.

@aderington
Copy link

I agree that the current PR could use some tweaks. I added a couple of comments to the PR with what I think is going on and a suggestion for improving the PR. I have not cloned the repo though, and I'm definitely not an expert in code generation, so take it with a grain of salt.

tl;dr;

"DELETE" -> {
  val hasBodyParameters = parameters.any { it is BodyParameter }
  if (hasBodyParameters) {
      this.addRequestSerializerStatement("delete")
  } else {
       this.add("\n.delete()")
  }
}

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

Successfully merging a pull request may close this issue.

3 participants