Skip to content

[BUG][typescript-angular] requestBody not sent with http DELETE request #10448

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

Closed
5 of 6 tasks
jbezuk opened this issue Sep 22, 2021 · 2 comments
Closed
5 of 6 tasks

[BUG][typescript-angular] requestBody not sent with http DELETE request #10448

jbezuk opened this issue Sep 22, 2021 · 2 comments

Comments

@jbezuk
Copy link

jbezuk commented Sep 22, 2021

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating an API using the "typescript-angular" generator with the following parameters:
--additional-properties ngVersion=11

Using the CLI which outputs version:
tor-cli version 5.3.0-SNAPSHOT

From an OAS 3 yaml file like the attached:

api.txt

The resulting method in the API service does not include the requestBody with the http delete request, like this:

delete.txt

Where the requestBody parameter should be included with the call to this.httpClient.delete.

openapi-generator version

Using the CLI outputs version:
tor-cli version 5.3.0-SNAPSHOT

I do not know if this is a regression.

Steps to reproduce

Place yaml file in working directory.
Run:

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \ -i /local/image-management-api.yml \ -g typescript-angular \ -o /local/out/typescript-angular \ --additional-properties ngVersion=11,npmName=my-api,npmVersion=0.1.0

Related issues/PRs

Could not find any open/closed issues similar for the typescript-angular generator.

Suggest a fix

Browsed the source for about an hour, didn't really see where to make a change.

@jbezuk
Copy link
Author

jbezuk commented Sep 23, 2021

I'm seeing now that GET also has this problem with request bodies, but interestingly PATCH and POST, and I think PUT use the parameter correctly. It's almost as if it was designed this way - am I mistaken in thinking it is normal to put request bodies in methods like get/delete? It seems supported generally by the spec.

EDIT: Now I see that request bodies are not supported by the Angular HttpClient.get method, and you have to put them in a different place for DELETE. Honestly it seems annoying that Angular tries to force this convention on you, but I definitely see now why the openapi-generator implementation doesn't work.

How hard do you think it would be to get this to work, at least for DELETE? Or perhaps throw an error when something in the yaml file can't be handled currently by the chosen generator?

@agravity-philipp
Copy link

As this optional body was added to the httpClient in Angular it should be included:
Angular PR

And OpenAPI Spec solved this on 30th May 2019 on their (OpenAPI TSC) as issue as well:
OpenAPI Spec Issue

Please include this so I could use this generator again.

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

No branches or pull requests

3 participants