-
-
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
[typescript-fetch] namespacing the generated request object types #3695
[typescript-fetch] namespacing the generated request object types #3695
Conversation
Fix OpenAPITools#1998 by namespacing the generated request object types used in the typescript-fetch client codegen.
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) |
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.
this is a breaking change, so this should either be configurable or we have to wait until 5.x to include it.
cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) |
@jgiles thanks for your PR! |
unset |
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'm not sure why the version is clobbered when I run the sample code re-generation. I can manually undo if necessary.
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.
are you sure you ran mvn clean package
before generating the samples? are you based on the latest master?
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'm based on 024f468 (master circa 2019-08-18).
If I run
mvn clean package
./bin/typescript-fetch-petstore-all.sh
on my current branch (where the .openapi-generator/VERSION
files already have "unset"), no sample files are changed. If I run it on master, the .openapi-generator/VERSION
files are overwritten to "unset".
FWIW, I (but no one else on my team) had this problem when running a brew-installed jar of of the old swagger-codegen, which is part of why we switched to running it in Docker... there could just be something weird in my local env.
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.
fixed manually
@macjohnny thanks for the speedy review! Per your suggestion, I have introduced a new CLI option for namespacing the request objects. I patterned the added option after existing options in the codegen class, let me know if adjustments are needed. Currently, the option defaults to false so that this would be mergeable into master for inclusion in the next patch release (I'm interested in making this available as soon as possible, since the fixed issue blocks my team's migration from the old swagger-codegen). However, it might be worth considering:
so that the fix is present by default. |
@jgiles thanks for the changes! I will review them soon |
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
@jgiles I think we can merge this and have this released in Lines 834 to 845 in 4575b30
https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml |
@jgiles by the way, would you like to add your company to https://github.com/OpenAPITools/openapi-generator#4---companiesprojects-using-openapi-generator ? |
I will add the Maven builds, and will check about adding company name :-) (I'm dropping offline for a little bit though, so it will be this evening probably) |
@macjohnny added the maven builds, fixed the version files. |
There's a build failure in the Maven stuff. The error looks to be for a different typescript-fetch sample, but I think the new one might also have problems. There's a bit of messiness in the setup of the sample tests, I might need some help getting that bit right. |
@jgiles the travis-error seems unrelated, but you need to register your Lines 834 to 845 in 4575b30
moreover, the If we don't manage to have the CI tests run, I would recommend to merge it without them, so this can be part of the next release, and add the CI tests in a separate PR. |
Thanks @macjohnny for the pointers! I am registering the I'm now doing the codegen for CI in the same way as the with-npm-version variant, which does produce the needed |
I would also be OK merging without the CI. What needs to happen in order to merge? |
@macjohnny also added Paxos to the list of companies using openapi-generator! |
I will merge it tomorrow if the ci build succeeds |
Can you please merge the most recent master into your branch? The unrelated typescript-axios build failure should be disabled |
Merged in latest master |
Using the "Requests" name invariably led to name conflicts between the Requests namespaces when there were multiple services (tags). This issue did reproduce in petstore - I'm not sure why CI didn't catch the compilation error. I've updated to use the service basename as a prefix (like "PetRequests") |
operations.put("namespaceParameterInterfaces", true); | ||
operations.put("paramIfaceIndent", " "); | ||
operations.put("paramIfaceSuffix", ""); | ||
operations.put("paramIfaceNsPrefix", "Requests."); | ||
operations.put("paramIfaceNsPrefix", operationList.get(0).baseName + "Requests."); |
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.
maybe this has to be sanitized, but we will see later
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{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\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.Description of the PR
Fix #1998 by namespacing the generated request object types used in the typescript-fetch client codegen.