rename php sever geneator, add php ze-ph generator

This commit is contained in:
wing328 2018-03-29 11:28:21 +08:00
parent 4d0bdf8aba
commit b41626d1e8
13 changed files with 446 additions and 112 deletions

View File

@ -3939,10 +3939,6 @@ public class DefaultCodegen implements CodegenConfig {
}
}
for (int i = 0; i < parameters.size(); i++) {
System.out.println("parmaeter name:" + parameters.get(i).baseName);
}
return parameters;
}

View File

@ -10,16 +10,15 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class LumenServerCodegen extends AbstractPhpCodegen
{
@SuppressWarnings("hiding")
public class PhpLumenServerCodegen extends AbstractPhpCodegen {
@SuppressWarnings("hiding")
protected String apiVersion = "1.0.0";
/**
* Configures the type of generator.
*
* @return the CodegenType for this generator
* @see org.openapitools.codegen.CodegenType
*
* @return the CodegenType for this generator
* @see org.openapitools.codegen.CodegenType
*/
public CodegenType getTag() {
return CodegenType.SERVER;
@ -28,7 +27,7 @@ public class LumenServerCodegen extends AbstractPhpCodegen
/**
* Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -l flag.
*
*
* @return the friendly name for the generator
*/
public String getName() {
@ -38,14 +37,14 @@ public class LumenServerCodegen extends AbstractPhpCodegen
/**
* Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here
*
*
* @return A string value for the help message
*/
public String getHelp() {
return "Generates a PHP Lumen server library.";
}
public LumenServerCodegen() {
public PhpLumenServerCodegen() {
super();
embeddedTemplateDir = templateDir = "lumen";
@ -88,13 +87,13 @@ public class LumenServerCodegen extends AbstractPhpCodegen
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
}
// override with any special post-processing
@ -113,7 +112,7 @@ public class LumenServerCodegen extends AbstractPhpCodegen
throw new IllegalArgumentException("'.' (dot) is not supported by PHP Lumen. Please refer to https://github.com/swagger-api/swagger-codegen/issues/6897 for more info.");
}
}
// sort the endpoints in ascending to avoid the route priority issure.
// https://github.com/swagger-api/swagger-codegen/issues/2643
Collections.sort(operations, new Comparator<CodegenOperation>() {

View File

@ -20,13 +20,13 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig {
public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage;
protected String groupId = "io.swagger";
protected String artifactId = "swagger-server";
protected String artifactVersion = "1.0.0";
public SilexServerCodegen() {
public PhpSilexServerCodegen() {
super();
invokerPackage = camelize("SwaggerServer");
@ -103,7 +103,9 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig
}
@Override
public String getName() {
public String getName()
{
return "php-silex";
}
@ -113,13 +115,13 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig
}
@Override
public String escapeReservedWord(String name) {
if(this.reservedWordsMappings().containsKey(name)) {
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "_" + name;
}
@Override
public String apiFileFolder() {
return (outputFolder + "/" + apiPackage()).replace('/', File.separatorChar);
@ -233,7 +235,7 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig
for (int i = 0; i < items.length; ++i) {
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
// camelize path variable
items[i] = "{" + camelize(items[i].substring(1, items[i].length()-1), true) + "}";
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
}
}

View File

@ -18,7 +18,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.regex.Matcher;
public class SlimFrameworkServerCodegen extends DefaultCodegen implements CodegenConfig {
public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage;
protected String srcBasePath = "lib";
protected String groupId = "io.swagger";
@ -29,7 +29,7 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
private String variableNamingConvention = "camelCase";
public SlimFrameworkServerCodegen() {
public PhpSlimServerCodegen() {
super();
// clear import mapping (from default generator) as slim does not use it
@ -120,8 +120,8 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
}
@Override
public String escapeReservedWord(String name) {
if(this.reservedWordsMappings().containsKey(name)) {
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "_" + name;
@ -199,11 +199,11 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
if ("camelCase".equals(variableNamingConvention)) {
// return the name in camelCase style
// phone_number => phoneNumber
name = camelize(name, true);
name = camelize(name, true);
} else { // default to snake case
// return the name in underscore style
// PhoneNumber => phone_number
name = underscore(name);
name = underscore(name);
}
// parameter name starting with number won't compile
@ -260,12 +260,12 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
}
return (getPackagePath() + File.separatorChar + basePath
// Replace period, backslash, forward slash with file separator in package name
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
// Trim prefix file separators from package path
.replaceAll(regFirstPathSeparator, ""))
// Trim trailing file separators from the overall path
.replaceAll(regLastPathSeparator+ "$", "");
// Replace period, backslash, forward slash with file separator in package name
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
// Trim prefix file separators from package path
.replaceAll(regFirstPathSeparator, ""))
// Trim trailing file separators from the overall path
.replaceAll(regLastPathSeparator + "$", "");
}
public String getPackagePath() {

View File

@ -0,0 +1,336 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.PathItem;
import org.openapitools.codegen.*;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.models.parameters.*;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodegen {
public static final String VEN_FROM_QUERY = "internal.ze-ph.fromQuery";
public static final String VEN_COLLECTION_FORMAT = "internal.ze-ph.collectionFormat";
public static final String VEN_QUERY_DATA_TYPE = "internal.ze-ph.queryDataType";
public static final String VEN_HAS_QUERY_DATA = "internal.ze-ph.hasQueryData";
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
@Override
public String getName() {
return "php-ze-ph";
}
@Override
public String getHelp() {
return "Generates PHP server stub using Zend Expressive ( https://zendframework.github.io/zend-expressive ) and Path Handler ( https://github.com/Articus/PathHandler ).";
}
public PhpZendExpressivePathHandlerServerCodegen() {
super();
//no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration
typeMapping.put("double", "float");
embeddedTemplateDir = templateDir = "ze-ph";
invokerPackage = "App";
packagePath = "";
srcBasePath = "src" + File.separator + "App";
apiDirName = "Handler";
modelDirName = "DTO";
apiPackage = invokerPackage + "\\" + apiDirName;
modelPackage = invokerPackage + "\\" + modelDirName;
apiTestTemplateFiles.clear();
modelTestTemplateFiles.clear();
apiDocTemplateFiles.clear();
modelDocTemplateFiles.clear();
supportingFiles.add(new SupportingFile("README.md.mustache", packagePath, "README.md"));
supportingFiles.add(new SupportingFile("composer.json.mustache", packagePath, "composer.json"));
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php"));
supportingFiles.add(new SupportingFile("container.php", packagePath + File.separator + "application", "container.php"));
supportingFiles.add(new SupportingFile("config.yml", packagePath + File.separator + "application", "config.yml"));
supportingFiles.add(new SupportingFile("app.yml.mustache", packagePath + File.separator + "application" + File.separator + "config", "app.yml"));
supportingFiles.add(new SupportingFile("path_handler.yml.mustache", packagePath + File.separator + "application" + File.separator + "config", "path_handler.yml"));
supportingFiles.add(new SupportingFile("data_transfer.yml.mustache", packagePath + File.separator + "application" + File.separator + "config", "data_transfer.yml"));
supportingFiles.add(new SupportingFile("ErrorMiddleware.php.mustache", packagePath + File.separator + srcBasePath, "ErrorMiddleware.php"));
supportingFiles.add(new SupportingFile("Date.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "Date.php"));
supportingFiles.add(new SupportingFile("DateTime.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "DateTime.php"));
supportingFiles.add(new SupportingFile("QueryParameter.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "QueryParameter.php"));
supportingFiles.add(new SupportingFile("QueryParameterArray.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Strategy", "QueryParameterArray.php"));
supportingFiles.add(new SupportingFile("Type.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Validator", "Type.php"));
supportingFiles.add(new SupportingFile("QueryParameterType.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Validator", "QueryParameterType.php"));
supportingFiles.add(new SupportingFile("QueryParameterArrayType.php.mustache", packagePath + File.separator + srcBasePath + File.separator + "Validator", "QueryParameterArrayType.php"));
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, "1.0.0");
}
/**
* Add operation to group
* Override of default grouping - group by resource path, not tag
*
* @param tag name of the tag
* @param resourcePath path of the resource
* @param operation Swagger Operation object
* @param co Codegen Operation object
* @param operations map of Codegen operations
*/
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
List<CodegenOperation> opList = operations.get(resourcePath);
if (opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(resourcePath, opList);
}
//ignore duplicate operation ids - that means that operation has several tags
int counter = 0;
for (CodegenOperation op : opList) {
if (co.operationId.equals(op.operationId)) {
counter++;
}
}
if (counter == 0) {
co.operationIdLowerCase = co.operationId.toLowerCase();
opList.add(co);
co.baseName = tag;
}
}
/**
* Return the file name of the Api Test
*
* @param name the file name of the Api
* @return the file name of the Api
*/
@Override
public String toApiFilename(String name) {
return toApiName(name);
}
/**
* Output the API (class) name (capitalized) ending with "Api"
* Return DefaultApi if name is empty
*
* @param name the name of the Api
* @return capitalized Api name ending with "Api"
*/
@Override
public String toApiName(String name) {
//Remove }
name = name.replaceAll("[\\}]", "");
return super.toModelName(name);
}
/**
* Generate additional model definitions from query parameters
*
* @param openAPI OpenAPI object
*/
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
super.preprocessOpenAPI(openAPI);
Map<String, PathItem> paths = openAPI.getPaths();
if (paths != null) {
for (String pathname : paths.keySet()) {
PathItem path = paths.get(pathname);
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
if (operationMap != null) {
for (HttpMethod method : operationMap.keySet()) {
Operation operation = operationMap.get(method);
Map<String, Schema> schemas = new HashMap<>();
if (operation == null || operation.getParameters() == null) {
continue;
}
for (Parameter parameter : operation.getParameters()) {
Schema schema = convertParameterToSchema(parameter);
if (schema != null) {
schemas.put(schema.getName(), schema);
}
}
if (!schemas.isEmpty()) {
Schema model = new Schema();
String operationId = getOrGenerateOperationId(operation, pathname, method.name());
model.setDescription("Query parameters for " + operationId);
model.setProperties(schemas);
model.getExtensions().put(VEN_FROM_QUERY, Boolean.TRUE);
String definitionName = generateUniqueDefinitionName(operationId + "QueryData", openAPI);
openAPI.getComponents().addSchemas(definitionName, model);
String definitionModel = "\\" + modelPackage + "\\" + toModelName(definitionName);
operation.getExtensions().put(VEN_QUERY_DATA_TYPE, definitionModel);
operation.getExtensions().put(VEN_HAS_QUERY_DATA, Boolean.TRUE);
}
}
}
}
}
}
protected Schema convertParameterToSchema(Parameter parameter) {
Schema property = null;
if (parameter instanceof QueryParameter) {
QueryParameter queryParameter = (QueryParameter) parameter;
// array
if (queryParameter.getSchema() instanceof ArraySchema) {
Schema inner = ((ArraySchema) queryParameter.getSchema()).getItems();
ArraySchema arraySchema = new ArraySchema();
arraySchema.setMinItems(queryParameter.getSchema().getMinItems());
arraySchema.setMaxItems(queryParameter.getSchema().getMaxItems());
arraySchema.setItems(inner);
String collectionFormat = getCollectionFormat(queryParameter);
if (collectionFormat == null) {
collectionFormat = "csv";
}
arraySchema.getExtensions().put(VEN_COLLECTION_FORMAT, collectionFormat);
property = arraySchema;
} else { // non-array e.g. string, integer
switch (queryParameter.getSchema().getType()) {
case "string":
StringSchema stringSchema = new StringSchema();
stringSchema.setMinLength(queryParameter.getSchema().getMinLength());
stringSchema.setMaxLength(queryParameter.getSchema().getMaxLength());
stringSchema.setPattern(queryParameter.getSchema().getPattern());
stringSchema.setEnum(queryParameter.getSchema().getEnum());
property = stringSchema;
break;
case "integer":
IntegerSchema integerSchema = new IntegerSchema();
integerSchema.setMinimum(queryParameter.getSchema().getMinimum());
integerSchema.setMaximum(queryParameter.getSchema().getMaximum());
property = integerSchema;
break;
case "number":
NumberSchema floatSchema = new NumberSchema();
floatSchema.setMinimum(queryParameter.getSchema().getMinimum());
floatSchema.setMaximum(queryParameter.getSchema().getMaximum());
property = floatSchema;
break;
case "boolean":
property = new BooleanSchema();
break;
case "date":
property = new DateSchema();
break;
case "date-time":
property = new DateTimeSchema();
break;
}
}
if (property != null) {
property.setName(queryParameter.getName());
property.setDescription(queryParameter.getDescription());
if (Boolean.TRUE.equals(queryParameter.getRequired())) {
List<String> required = new ArrayList<String>();
required.add(queryParameter.getName());
}
property.getExtensions().put(VEN_FROM_QUERY, Boolean.TRUE);
}
}
return property;
}
protected String generateUniqueDefinitionName(String name, OpenAPI openAPI) {
String result = name;
if (openAPI.getComponents().getSchemas() != null) {
int count = 1;
while (openAPI.getComponents().getSchemas().containsKey(result)) {
result = name + "_" + count;
count += 1;
}
}
return result;
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
objs = super.postProcessOperations(objs);
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
String interfaceToImplement;
StringBuilder interfacesToImplement = new StringBuilder();
String classMethod;
String pathPattern = null;
for (CodegenOperation op : operationList) {
switch (op.httpMethod) {
case "GET":
interfaceToImplement = "Operation\\GetInterface";
classMethod = "handleGet";
break;
case "POST":
interfaceToImplement = "Operation\\PostInterface";
classMethod = "handlePost";
break;
case "PATCH":
interfaceToImplement = "Operation\\PatchInterface";
classMethod = "handlePatch";
break;
case "PUT":
interfaceToImplement = "Operation\\PutInterface";
classMethod = "handlePut";
break;
case "DELETE":
interfaceToImplement = "Operation\\DeleteInterface";
classMethod = "handleDelete";
break;
default:
throw new RuntimeException("Unknown HTTP Method " + op.httpMethod + " not allowed");
}
if (interfacesToImplement.length() > 0) {
interfacesToImplement.append(", ");
}
interfacesToImplement.append(interfaceToImplement);
op.httpMethod = classMethod;
//All operations have same path because of custom operation grouping, so path pattern can be calculated only once
if (pathPattern == null) {
pathPattern = generatePathPattern(op);
}
}
operations.put("interfacesToImplement", interfacesToImplement.toString());
operations.put("pathPattern", pathPattern);
return objs;
}
protected String generatePathPattern(CodegenOperation op) {
String result = op.path;
for (CodegenParameter pp : op.pathParams) {
StringBuilder replacement = new StringBuilder("{" + pp.paramName);
if (pp.isEnum) {
StringBuilder enumRegExp = new StringBuilder();
for (String enumValue : pp._enum) {
if (enumRegExp.length() > 0) {
enumRegExp.append("|");
}
enumRegExp.append(enumValue.replaceAll("[\\Q<>()[]{}|^$-=!?*+.\\\\E]", "\\\\$0"));
}
replacement.append(":");
replacement.append(enumRegExp);
} else if (pp.isInteger) {
replacement.append(":0|(?:-?[1-9][0-9]*)");
} else if (pp.isString && (pp.pattern != null) && (!pp.pattern.isEmpty())) {
replacement.append(":");
replacement.append(pp.pattern);
}
//TODO add regular expressions for other types if they are actually used for path parameters
replacement.append("}");
result = result.replace("{" + pp.paramName + "}", replacement);
}
return result;
}
}

View File

@ -12,7 +12,10 @@ org.openapitools.codegen.languages.KotlinServerCodegen
org.openapitools.codegen.languages.HaskellServantCodegen
org.openapitools.codegen.languages.JavascriptClientCodegen
org.openapitools.codegen.languages.LuaClientCodegen
org.openapitools.codegen.languages.LumenServerCodegen
org.openapitools.codegen.languages.PhpLumenServerCodegen
org.openapitools.codegen.languages.PhpSlimServerCodegen
org.openapitools.codegen.languages.PhpSilexServerCodegen
org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen
org.openapitools.codegen.languages.ObjcClientCodegen
org.openapitools.codegen.languages.PerlClientCodegen
org.openapitools.codegen.languages.PhpClientCodegen
@ -24,8 +27,6 @@ org.openapitools.codegen.languages.RClientCodegen
org.openapitools.codegen.languages.RubyOnRailsServerCodegen
org.openapitools.codegen.languages.RubyClientCodegen
org.openapitools.codegen.languages.ScalaClientCodegen
org.openapitools.codegen.languages.SlimFrameworkServerCodegen
org.openapitools.codegen.languages.SilexServerCodegen
org.openapitools.codegen.languages.SinatraServerCodegen
org.openapitools.codegen.languages.TizenClientCodegen
org.openapitools.codegen.languages.TypeScriptAngularClientCodegen

View File

@ -1,51 +0,0 @@
package org.openapitools.codegen.lumen;
import org.openapitools.codegen.AbstractOptionsTest;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.languages.LumenServerCodegen;
import org.openapitools.codegen.options.LumenServerOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
public class LumenServerOptionsTest extends AbstractOptionsTest {
@Tested
private LumenServerCodegen clientCodegen;
public LumenServerOptionsTest() {
super(new LumenServerOptionsProvider());
}
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(LumenServerOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setParameterNamingConvention(LumenServerOptionsProvider.VARIABLE_NAMING_CONVENTION_VALUE);
clientCodegen.setModelPackage(LumenServerOptionsProvider.MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(LumenServerOptionsProvider.API_PACKAGE_VALUE);
times = 1;
times = 1;
clientCodegen.setInvokerPackage(LumenServerOptionsProvider.INVOKER_PACKAGE_VALUE);
times = 1;
clientCodegen.setPackagePath(LumenServerOptionsProvider.PACKAGE_PATH_VALUE);
times = 1;
clientCodegen.setSrcBasePath(LumenServerOptionsProvider.SRC_BASE_PATH_VALUE);
times = 1;
clientCodegen.setGitUserId(LumenServerOptionsProvider.GIT_USER_ID_VALUE);
times = 1;
clientCodegen.setGitRepoId(LumenServerOptionsProvider.GIT_REPO_ID_VALUE);
times = 1;
clientCodegen.setArtifactVersion(LumenServerOptionsProvider.ARTIFACT_VERSION_VALUE);
times = 1;
}};
}
}

View File

@ -0,0 +1,51 @@
package org.openapitools.codegen.lumen;
import org.openapitools.codegen.AbstractOptionsTest;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.languages.PhpLumenServerCodegen;
import org.openapitools.codegen.options.PhpLumenServerOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
public class PhpLumenServerOptionsTest extends AbstractOptionsTest {
@Tested
private PhpLumenServerCodegen clientCodegen;
public PhpLumenServerOptionsTest() {
super(new PhpLumenServerOptionsProvider());
}
@Override
protected CodegenConfig getCodegenConfig() {
return clientCodegen;
}
@SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(PhpLumenServerOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setParameterNamingConvention(PhpLumenServerOptionsProvider.VARIABLE_NAMING_CONVENTION_VALUE);
clientCodegen.setModelPackage(PhpLumenServerOptionsProvider.MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(PhpLumenServerOptionsProvider.API_PACKAGE_VALUE);
times = 1;
times = 1;
clientCodegen.setInvokerPackage(PhpLumenServerOptionsProvider.INVOKER_PACKAGE_VALUE);
times = 1;
clientCodegen.setPackagePath(PhpLumenServerOptionsProvider.PACKAGE_PATH_VALUE);
times = 1;
clientCodegen.setSrcBasePath(PhpLumenServerOptionsProvider.SRC_BASE_PATH_VALUE);
times = 1;
clientCodegen.setGitUserId(PhpLumenServerOptionsProvider.GIT_USER_ID_VALUE);
times = 1;
clientCodegen.setGitRepoId(PhpLumenServerOptionsProvider.GIT_REPO_ID_VALUE);
times = 1;
clientCodegen.setArtifactVersion(PhpLumenServerOptionsProvider.ARTIFACT_VERSION_VALUE);
times = 1;
}};
}
}

View File

@ -2,19 +2,19 @@ package org.openapitools.codegen.silex;
import org.openapitools.codegen.AbstractOptionsTest;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.languages.SilexServerCodegen;
import org.openapitools.codegen.options.SilexServerOptionsProvider;
import org.openapitools.codegen.languages.PhpSilexServerCodegen;
import org.openapitools.codegen.options.PhpSilexServerOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
public class SilexServerOptionsTest extends AbstractOptionsTest {
public class PhpSilexServerOptionsTest extends AbstractOptionsTest {
@Tested
private SilexServerCodegen clientCodegen;
private PhpSilexServerCodegen clientCodegen;
public SilexServerOptionsTest() {
super(new SilexServerOptionsProvider());
public PhpSilexServerOptionsTest() {
super(new PhpSilexServerOptionsProvider());
}
@Override
@ -26,7 +26,7 @@ public class SilexServerOptionsTest extends AbstractOptionsTest {
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SilexServerOptionsProvider.SORT_PARAMS_VALUE));
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(PhpSilexServerOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
}};
}

View File

@ -2,19 +2,19 @@ package org.openapitools.codegen.slim;
import org.openapitools.codegen.AbstractOptionsTest;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.languages.SlimFrameworkServerCodegen;
import org.openapitools.codegen.options.SlimFrameworkServerOptionsProvider;
import org.openapitools.codegen.languages.PhpSlimServerCodegen;
import org.openapitools.codegen.options.PhpSlimServerOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
public class SlimFrameworkServerOptionsTest extends AbstractOptionsTest {
public class PhpSlimServerOptionsTest extends AbstractOptionsTest {
@Tested
private SlimFrameworkServerCodegen clientCodegen;
private PhpSlimServerCodegen clientCodegen;
public SlimFrameworkServerOptionsTest() {
super(new SlimFrameworkServerOptionsProvider());
public PhpSlimServerOptionsTest() {
super(new PhpSlimServerOptionsProvider());
}
@Override
@ -26,7 +26,7 @@ public class SlimFrameworkServerOptionsTest extends AbstractOptionsTest {
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SlimFrameworkServerOptionsProvider.SORT_PARAMS_VALUE));
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(PhpSlimServerOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
}};
}

View File

@ -7,7 +7,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class LumenServerOptionsProvider implements OptionsProvider {
public class PhpLumenServerOptionsProvider implements OptionsProvider {
public static final String MODEL_PACKAGE_VALUE = "package";
public static final String API_PACKAGE_VALUE = "apiPackage";
public static final String SORT_PARAMS_VALUE = "false";

View File

@ -6,7 +6,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class SilexServerOptionsProvider implements OptionsProvider {
public class PhpSilexServerOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";

View File

@ -6,7 +6,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class SlimFrameworkServerOptionsProvider implements OptionsProvider {
public class PhpSlimServerOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";