mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
Process server port (#2782)
This commit is contained in:
parent
1c16d9a9e8
commit
d112eea088
@ -17,11 +17,16 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
|
||||
@ -188,7 +193,14 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
String port = URLPathUtils.getPort(url, "8080");
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
|
||||
|
@ -53,6 +53,17 @@ To run the server
|
||||
./build/src/cpp-qt5-qhttpengine-server &
|
||||
```
|
||||
|
||||
To override the default port via the command line, provide the parameters `port` and `address` like below
|
||||
|
||||
```shell
|
||||
cpp-qt5-qhttpengine-server --port 9080 --address 127.17.0.1
|
||||
```
|
||||
or
|
||||
|
||||
```shell
|
||||
cpp-qt5-qhttpengine-server -p 9080 -a 127.17.0.1
|
||||
```
|
||||
|
||||
#### Invoke an API
|
||||
|
||||
```shell
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char * argv[])
|
||||
QStringList() << "p" << "port",
|
||||
"port to listen on",
|
||||
"port",
|
||||
"8080"
|
||||
"{{serverPort}}"
|
||||
);
|
||||
parser.addOption(portOption);
|
||||
parser.addHelpOption();
|
||||
|
Loading…
Reference in New Issue
Block a user