forked from loafle/openapi-generator-original
[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:
parent
4e62e92daf
commit
b87806834b
@ -31,6 +31,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +66,14 @@ public class OpenAPIDocumentationConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket customImplementation(){
|
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)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.host(host)
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("org.openapitools.codegen.online.api"))
|
.apis(RequestHandlerSelectors.basePackage("org.openapitools.codegen.online.api"))
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user