-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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-axios] Implement useSingleRequestParameter option #6288
[typescript-axios] Implement useSingleRequestParameter option #6288
Conversation
- New options `useSingleRequestParameter` to use a single param for the request, instead of one param per request param.
Include new parameter `useSingleRequestParameter`. Default value = `false` to keep compatibility with previous versions.
Also included script in the script that runs all
- Previous samples have a minor change (one line is deleted) - New sample generated with the new parameter set to true
👍 Thanks for opening this issue! The team will review the labels and make any necessary 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.
LGTM
thanks a lot for your PR. Please add the windows scripts and we should be good to go.
@@ -4,5 +4,6 @@ | |||
./bin/typescript-axios-petstore-with-npm-version.sh | |||
./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh | |||
./bin/typescript-axios-petstore-with-complex-headers.sh | |||
./bin/typescript-axios-petstore-with-single-request-parameters.sh |
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.
please also add a windows version to the corresponding bin/windows/typescript-axios-petstore-all.bat
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.
somehow the changes to the allowed parameters are still missing:
see e.g. https://github.com/OpenAPITools/openapi-generator/pull/4479/files#diff-0c001a8f6a2f4306967815c6f6979681R62
@macjohnny I've pushed two commits for your comments, I'm not 100% sure about the changes about the allowed parameters though: I guess adding those lines only affects the message shown when using the CLI, right? Since the new variable was being read in |
@codeserk please update the doc file according to the ci: |
@macjohnny Thanks for the quick review, and for helping maintaining this awesome repository :) Would it make sense if I made another PR but for the current latest version |
* master: Update username (arun-nalla) (#6319) [typescript-axios] Implement useSingleRequestParameter option (#6288) [typescript] Remove "v4-compat" value of enumSuffix (#6308) Mark swift4 generator as deprecated (#6311) Remove @nickmeinhold from Dart technical committee (#6309) Migrate Erlang samples to use OAS 3 spec (#6297) update dart samples Improve parameter documentation (#6092) Minor improvements to `plantuml` doc generator (#6298) undo changes to petstore.yaml oas3.0 (#6299) Allow passing progress callbacks through client methods. (#6261) Create method to json (#6111)
@codeserk it will be released with version 5.0.0, due in june. If you want to use it now, simply use the 5.0.0-SNAPSHOT version |
Did you manage to start using it? If so how? @codeserk Maybe you can elaborate @macjohnny would be much appreciated. I am unable to get it working, currently using a script in package.json like this |
@standayweb I was unable to make it work with
docker build -f ./Dockerfile -t <name of your image> .
docker run --rm -v ${PWD}:/local <name of your image> generate -i <location for you schema> -g typescript-axios -o /local/src/generated --additional-properties=useSingleRequestParameter=true Of course, replace As said, not sure if this is the best solution, but I couldn't find version 5 in the docker registry |
you can download the snapshot version here: |
thanks for your work @codeserk! |
For those who were like me and still confused by the instructions for using the 5.0.0-SNASHOT version with Docker, here's what I did:
EDIT: oops I was wrong, it all works! #6288 (comment) |
@benwiley4000 Please try
then verify the |
@wing328 I'm sorry, I actually re-verified my output and it was correct. I was switching over from a different generator and didn't realize there would be the private internal function with ordered parameters as well as the public version with the single request parameter. Thanks and sorry for the confusion! 🙂 |
@benwiley4000 no problem at all. |
After openapi.json is updated, the InlineObject number has changed, causing all interfaces to be modified😢. |
@mushan0x0 can you please open a new issue and give a short example? |
This is a follow-up story that completes this PR proposed before. This PR adds a new parameter that has default value to false to maintain retro-compatibility.
Problem
The current implementation expands all the parameters in the API methods:
This is especially problematic when adding more fields to existing endpoints, since the order of the parameters might change. This leads to a breaking changes in the generated client, even if the API introduced a non-breaking change (a new optional parameter).
Proposal
Adding a new parameter
useSingleRequestParameter
to combine all the request parameters in a single object. This is not a new solution, it has been implemented in other generators and there is already a proposed solution using this mechanism. This new option is disabled by default, to keep compatibility with previous versionsInterfaces for the requests
Changes in the methods to use the request interfaces
Review
I've split the changes in different commits to ease the review process. The last commit contains the highest number of changes: I've regenerated all the samples.
@macjohnny I believe you were the reviewer of the previous PR and asked for some changes in the previous proposal. Please let me know if there's something missing (I'm pretty new with
mustache
and this is my first contribution to this project so I might have messed up something :D)@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir @petejohansonxo @amakhrov