swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.81k stars 6.02k forks source link

[JAVA] swagger-codegen ApiClient with Security/SSL #3866

Open sqmuser opened 7 years ago

sqmuser commented 7 years ago
Description

Question on Swagger's generated code for ApiClient. I noticed that you have a sample that generates SSL code for ApiClient. My Rest API uses swagger and gradle to generate the Rest API. I would like to know how to generate the same type of ApiClient with the use of SSL.My yaml spec has both 'http' and 'https' as schemes but does not produce any generated code that uses SSL.

I would like to be able to generate the sample ApiClient as shown below:

https://github.com/swagger-api/swagger-codegen/blob/c5724a46d6cbbed03d292a361b3a0d07d1a64dae/samples/client/petstore-security-test/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java

Appreciate any input you can give.

sqmuser commented 7 years ago

BTW. The API uses Jersey client. I noticed that the sample petstore did not generate any ssl for ApiClient. It only generated it for GSON.

wing328 commented 7 years ago

@sqmuser do you mean you're looking for an option to disable SSL/TLS validation in the Java API client?

sqmuser commented 7 years ago

Hi - Thanks for the reply. I have a self-signed certificate and I have set the ssl parameters through JVM's System Property (keystore, kpass, truststore, tpass). I am looking for an option to generate ApiClient.java with the option to enable SSL/TLS . I am using swagger-codegen-plugin:1.3.