-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[BUG] [typescript-angular] DELETE method - TS2554: Expected 1-2 arguments, but got 3 #10864
Comments
I see the same issue here with ng 13.0.1 and generator 5.3.1-SNAPSHOT |
I'm seeing the same issue with:
I ran: Also seems like the methods like https://github.com/angular/angular/blob/13.1.1/packages/common/http/src/client.ts#L941-L949 Once, it took a middle argument, So it seems like a bug :) |
There is a PR for this here #10976 |
Isn't the fix simply to use the options.body property instead (as suggested in #11172 )? I'm actually in need of a body for DELETE. |
Duplicate of #10975 |
@coder925 Unfortunately, the specification does not allow a body for delete methods. See https://swagger.io/specification/#operation-object mentionning
|
Hey guys, link to comment. I do not have a requestBody but still have the same issue. |
Same issue as @EE1234EE , I have a delete method without any request body and still get this issue. Here is my specification: delete:
summary: Deletes a user by ID.
operationId: 'deleteById'
tags:
- User
parameters:
- name: userId
in: path
required: true
description: This is the user identifier.
schema:
type: integer
format: int64
responses:
'204':
description: The user has been successfuly deleted.
'404':
description: The user could not be deleted because it doesn't exist.
content:
application/json:
schema:
$ref: './resources/shared/ServiceError.yaml' |
The generator is attempting to add the request body whether it is in your specification or not that is why you are seeing the issues |
any updates regarding this issue? |
@pwiesinger a fix for this was merged in #10976 we are just waiting for a release that includes it |
There was a long ongoing discussion about delete bodies over here: OAI/OpenAPI-Specification#1801 Therefore I would vote to "revert the revert" and add proper support for bodies in delete methods. 😁 |
I am attempting to do so. What prompted the revert was that I couldn't produce a valid test spec with a delete body, but I hadn't noticed it was still using swagger v2. |
So just checking, a release with the proposed fixes isn't out yet? Right? If so how can we circumvent this issue while using ng13 and openapi generator? |
Using version 5.3.0 still seems to work with a13 for us at least |
With version 5.4.0 I'm also getting this error. Using the decorators from @Delete(':id')
@ApiOkResponse({
type: Boolean,
})
@ApiParam({ name: 'id' })
remove(@Param('id') id: string) {
return this.projectsService.remove(id);
} |
We overided the api.service.mustache as quickfix that uses the options.body for deletes. Its a bit dirty but it works for us for now: api.service.mustache.zip We use version 5.3.1 |
where did you get this version? 2.4.26 is the latest |
@yurakhomitsky You're talking about the version of |
That's great but when this bug will be fixed and shipped via npm package? |
The bug is not in the npm package but in the external dependency it downloads. See the README:
The fix is in |
Sounds like I will have to push the Also, the problem doesn't appear on this version of the package I guess it generates the code of the Angular 11 version. |
Has this bug been resolved? I just upgraded from 5.4.0 (where I saw the bug) to 6.2.0, and so far it seems to be okay. |
@paintcode Yes it has been fixed. This bug report effectively duplicates #10975 and as such should have been closed together with that one. |
what version was this fixed in? |
Broken compilation was fixed in 6.0.0 (but still no body support in DELETE) |
Ran into the same issues. Out of the blue I couldn't generate code for DELETE endpoints anymore. Updating to the latest Solved it by setting the 'ngVersion' additional-property to '12.0.0' (although the project is on v14) in the command:
setting it to any major version above "12.0.0" will break the code generation. |
Description
It generates a wrong way to call the HttpClient.delete method
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Generate from the DELETE method definition
Suggest a fix
In case of the DELETE method do not provide the body payload
The text was updated successfully, but these errors were encountered: