[online] Honor GENERATOR_HOST env variable (#3263)

This sets "host" appropriately to the published host when GENERATOR_HOST
is configured.
This commit is contained in:
Jim Schubert 2019-07-02 09:15:18 -04:00 committed by GitHub
parent 4e62e92daf
commit b87806834b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;
@ -64,7 +66,14 @@ public class OpenAPIDocumentationConfig {
@Bean
public Docket customImplementation(){
String host;
try {
host = new URI(System.getProperty("GENERATOR_HOST", "http://localhost")).getHost();
} catch (URISyntaxException e) {
host = "";
}
return new Docket(DocumentationType.SWAGGER_2)
.host(host)
.select()
.apis(RequestHandlerSelectors.basePackage("org.openapitools.codegen.online.api"))
.build()