Skip to content

[java/resttemplate] Generate valid code if no Authentication implementations present #2861

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
wants to merge 1 commit into from

Conversation

jonfreedman
Copy link
Contributor

Take the logic used to decide which instances to add to the authentications map and re-use to not import classes or offer non-functional util methods

@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog

…tations present

Take the logic used to decide which instances to add to the authentications map and re-use to not import classes or offer non-functional util methods
@wing328 wing328 added this to the 4.0.0 milestone May 11, 2019
@wing328
Copy link
Member

wing328 commented May 11, 2019

@jonfreedman thanks for the PR. Look like the change will results in duplicated import org.openapitools.client.auth.ApiKeyAuth:

--- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java
@@ -59,12 +59,12 @@ import java.util.Map.Entry;
 import java.util.TimeZone;
 
 import org.openapitools.client.auth.Authentication;
-import org.openapitools.client.auth.HttpBasicAuth;
-import org.openapitools.client.auth.HttpBearerAuth;
+
+import org.openapitools.client.auth.ApiKeyAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
+import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.OAuth;

@jonfreedman
Copy link
Contributor Author

Can you please check the population of the authentications map, if there's a duplicate import I guess there must be a duplicate put too?
If that's the case do you think it's better to add more variables like hasOAuthMethods instead?

@wing328
Copy link
Member

wing328 commented May 11, 2019

@jonfreedman
Copy link
Contributor Author

Yep I saw that one, but would also need hasBasicAuthMethods, hasTokenAuthMethods etc. which I assume don't exist yet?

@wing328 wing328 modified the milestones: 4.0.0, 4.0.1 May 13, 2019
@wing328
Copy link
Member

wing328 commented May 20, 2019

but would also need hasBasicAuthMethods, hasTokenAuthMethods etc. which I assume don't exist yet?

Can you please add hasBasicAuthMethods, hasTokenAuthMethods, etc as part of this PR?

@jonfreedman
Copy link
Contributor Author

I can give it a go - can you point me in the right direction?

@wing328
Copy link
Member

wing328 commented May 20, 2019

private boolean hasOAuthMethods(List<CodegenSecurity> authMethods) {
is a good starting point.

And then add similar checks in

Let me know if you need further info.

Thanks for helping us to add these methods.

@wing328 wing328 modified the milestones: 4.0.1, 4.0.2 May 31, 2019
@wing328 wing328 modified the milestones: 4.0.2, 4.0.3 Jun 20, 2019
@wing328 wing328 modified the milestones: 4.0.3, 4.1.0 Jul 9, 2019
@wing328 wing328 modified the milestones: 4.1.0, 4.1.1 Aug 9, 2019
@wing328 wing328 modified the milestones: 4.1.1, 4.1.2 Aug 26, 2019
@wing328 wing328 modified the milestones: 4.1.2, 4.1.3 Sep 11, 2019
@wing328 wing328 modified the milestones: 4.1.3, 4.2.0 Oct 4, 2019
@wing328 wing328 removed this from the 4.2.0 milestone Oct 30, 2019
@wing328
Copy link
Member

wing328 commented Jan 24, 2020

Closing this as there's no update. Please open a new one when you've time.

Thanks again for the PR.

@wing328 wing328 closed this Jan 24, 2020
jonfreedman added a commit to jonfreedman/openapi-generator that referenced this pull request Apr 1, 2020
wing328 pushed a commit that referenced this pull request May 23, 2020
…nt (#5788)

* generate valid code if no Authentication implementations present

resurrects #2861

* remove what I assume are human generated test cases

* need to iterate over authMethods in order to pull out name

* fix another test

* update more tests

* rename hasTokenAuthMethods to hasApiKeyAuthMethods

* remove duplicate methods, fix hasHttpBearerMethods check

* update templates

* update windows java-petstore files

* update windows java-petstore files

* re-generate

* re-generate

* restore samples.ci tests

* restore samples.ci tests
therve pushed a commit to DataDog/datadog-api-client-java that referenced this pull request Mar 23, 2021
…nt (#5788)

* generate valid code if no Authentication implementations present

resurrects OpenAPITools/openapi-generator#2861

* remove what I assume are human generated test cases

* need to iterate over authMethods in order to pull out name

* fix another test

* update more tests

* rename hasTokenAuthMethods to hasApiKeyAuthMethods

* remove duplicate methods, fix hasHttpBearerMethods check

* update templates

* update windows java-petstore files

* update windows java-petstore files

* re-generate

* re-generate

* restore samples.ci tests

* restore samples.ci tests
api-clients-generation-pipeline bot pushed a commit to DataDog/datadog-api-client-java that referenced this pull request Sep 8, 2021
…nt (#5788)

* generate valid code if no Authentication implementations present

resurrects OpenAPITools/openapi-generator#2861

* remove what I assume are human generated test cases

* need to iterate over authMethods in order to pull out name

* fix another test

* update more tests

* rename hasTokenAuthMethods to hasApiKeyAuthMethods

* remove duplicate methods, fix hasHttpBearerMethods check

* update templates

* update windows java-petstore files

* update windows java-petstore files

* re-generate

* re-generate

* restore samples.ci tests

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

Successfully merging this pull request may close these issues.

2 participants