-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[TypeScript][Angular] fix issues with empty body #6754
[TypeScript][Angular] fix issues with empty body #6754
Conversation
* Check if act as Restful update method | ||
* | ||
* @return true if act as Restful update method, false otherwise | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment is wrong 😉 this is what I came up with, but wasn't fast enough to create a PR
/**
* Check if body param is allowed for the request method
*
* @return true if request method is PUT, PATCH or POST; false otherwise
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, now I see it. I updated the PR accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macjohnny update the comment in the java file, otherwise it looks cool, thx for creating the PR 👍
@wing328 you can mark this one also with bug and typescript |
@wing328 @sebastianhaas the checks passed, how about merging? |
Hello! I was having some trouble with delete calls (it was passing 3 parameters, when the delete method can only take 2), so @macjohnny asked me to try this branch to see if it fixed the problem. While it does fix the parameter mismatch, it doesn't quite fix the problem altogether. This is the API I've been using, with the contacts->delete method. As you can see, it wants a list of contact_ids in the body of the request. This PR still has an issue where it doesn't pass body data for delete requests at all (which is valid swagger, even if it's uncommon). As I understand it, Angular does not currently support body data in the options of the delete method. As an alternative, the request method does. If we used request instead, we could have full control over what gets passed around. I don't have much experience with mustache templates, but I also think it's worth considering using the request method for all of the call types. It would be more consistent, so it might simplify the template in the long run. I'm open to input on this, if anyone has any particular thoughts on using one over the other. |
@defmonk0 either that, or you could try and file a request with the Angular team. Not sure if body data in a delete is inside specs though, so they might as well not agree on doing this. Would be interesting to do some research on that, maybe I'll find some time today. |
@defmonk0 @sebastianhaas the HTTP standard does not explicitly forbid body data with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a useful addition, but maybe @wing328 needs to step in here as this is a more general question to me, whether swagger codegen wants to enforce APIs to comply with standards or tries to maximize compatibility.
Approved = <any> 'approved', | ||
Delivered = <any> 'delivered' | ||
} | ||
export type StatusEnum = 'placed' | 'approved' | 'delivered'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why you got these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -21,3 +21,5 @@ export interface Tag { | |||
name?: string; | |||
|
|||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And these empty lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, and did someone delete the newline at the end? And does your output contain one or two blank lines in the end? It appears to be two, but maybe that's just Github
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastianhaas i cannot tell where the newlines come from, but they also appear in e.g. #6769, so it is just about re-generating the files
@sebastianhaas so does this PR look good to you? |
Yes, I guess so, I'm always in favor of enforcing standards, however, for a project like a codegen it might also be sensible to maximize compatibility. Maybe using an option flag though. |
@sebastianhaas alright, but I suggest to merge this PR and discuss the |
@sebastianhaas / @macjohnny / @defmonk0 FYI - it seems more of an incomplete typescript restriction, than actually intended use case that DELETE would allow to set a body when using the My reasoning is based on the following method signature:
and here are the constructors for HttpRequest:
|
@pgrm good catch, even more so, let's merge this PR and discuss options re compatibility with non-standard API definitions in another place. |
If no more feedback/question on this, I'll merge this tomorrow (Tue) |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.Description of the PR
fixes #6649, #6723