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.74k stars 6.02k forks source link

Swagger CodeGen HTTPS SSL/TLS Connectivity #3643

Open erdarun opened 7 years ago

erdarun commented 7 years ago
Description

We have our service integrated with Swagger OpenAPI Spec and published on HTTPS URL.

Need to create swagger codegen client for java, javascript pointing to swagger yaml published on HTTPS.

When tried below command got SSLHandshakeError.

"swagger-codegen generate -i https://SERVER_IP:443/api/swagger.yaml -l java -o java-api/."

Also when swagger codegen generates client will it have Mutual SSL/TLS code for https swagger spec url?

Tried against HTTP URL working but need here is for HTTPS.

Swagger-codegen version

2.1.6

Swagger declaration file content or url
Command line used for generation

swagger-codegen generate -i https://SERVER_IP:443/api/swagger.yaml -l java -o java-api/.

Steps to reproduce
Related issues
Suggest a Fix

Swagger Codegen support for HTTPS YAML/JSON OpenAPI Spec.

Client code generated should have mutual SSL/TLS code for testing against HTTPS URL.

cbornet commented 7 years ago

As a workaround, you could first download the spec with a tool like curl

ePaul commented 7 years ago

Does it work if you use a domain name instead of an IP address? (I vaguely remember that I did something like this once, downloading the yaml from Github via HTTPS.)

I guess the problem is that your TLS certificate just binds the domain name to the key, not the IP address (I don't even know whether the latter is possible), and thus the HTTPS support in your JVM doesn't accept the certificate. There is not much which can be done here from Swagger-Codegen.