mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
added connexion
This commit is contained in:
parent
5db7f6ebb9
commit
7f62576d88
@ -305,7 +305,8 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
|||||||
-o samples/client/petstore/java \
|
-o samples/client/petstore/java \
|
||||||
-c path/to/config.json
|
-c path/to/config.json
|
||||||
```
|
```
|
||||||
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
|
Supported config options can be different per language. Running `config-help -l {lang}` will show available options. **These options are applied
|
||||||
|
by passing them with `-D{optionName}={optionValue}**.
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java
|
||||||
|
@ -14,9 +14,14 @@ import java.io.File;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConfig {
|
public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
||||||
|
public static final String DEFAULT_CONTROLLER = "defaultController";
|
||||||
|
|
||||||
protected String apiVersion = "1.0.0";
|
protected String apiVersion = "1.0.0";
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
protected String projectName = "swagger-server";
|
protected String projectName = "swagger-server";
|
||||||
|
protected String controllerPackage;
|
||||||
|
protected String defaultController;
|
||||||
|
|
||||||
public FlaskConnexionCodegen() {
|
public FlaskConnexionCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -92,16 +97,42 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
"README.md")
|
"README.md")
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!new java.io.File("controllers/default_controller.py").exists()) {
|
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
|
||||||
|
defaultValue("controllers"));
|
||||||
|
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
|
||||||
|
defaultValue("default_controller"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
apiTemplateFiles.clear();
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CONTROLLER_PACKAGE)) {
|
||||||
|
this.controllerPackage = additionalProperties.get(CONTROLLER_PACKAGE).toString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.controllerPackage = "controllers";
|
||||||
|
additionalProperties.put(CONTROLLER_PACKAGE, this.controllerPackage);
|
||||||
|
}
|
||||||
|
if (additionalProperties.containsKey(DEFAULT_CONTROLLER)) {
|
||||||
|
this.defaultController = additionalProperties.get(DEFAULT_CONTROLLER).toString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.defaultController = "default_controller";
|
||||||
|
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!new java.io.File(controllerPackage + File.separator + defaultController + ".py").exists()) {
|
||||||
supportingFiles.add(new SupportingFile("controller.mustache",
|
supportingFiles.add(new SupportingFile("controller.mustache",
|
||||||
"controllers",
|
controllerPackage,
|
||||||
"default_controller.py")
|
defaultController + ".py")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String apiPackage() {
|
public String apiPackage() {
|
||||||
return "controllers";
|
return controllerPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +209,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
String operationId = operation.getOperationId();
|
String operationId = operation.getOperationId();
|
||||||
if(operationId != null && operationId.indexOf(".") == -1) {
|
if(operationId != null && operationId.indexOf(".") == -1) {
|
||||||
operation.setVendorExtension("x-operationId", underscore(sanitizeName(operationId)));
|
operation.setVendorExtension("x-operationId", underscore(sanitizeName(operationId)));
|
||||||
operationId = "controllers.default_controller." + underscore(sanitizeName(operationId));
|
operationId = controllerPackage + "." + defaultController + "." + underscore(sanitizeName(operationId));
|
||||||
operation.setOperationId(operationId);
|
operation.setOperationId(operationId);
|
||||||
}
|
}
|
||||||
if(operation.getTags() != null) {
|
if(operation.getTags() != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user