forked from loafle/openapi-generator-original
Merge remote-tracking branch 'upstream/master' into add-auth-annotations-jaxrs
This commit is contained in:
commit
b83db8e535
@ -67,6 +67,8 @@ public interface CodegenConfig {
|
||||
|
||||
CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions);
|
||||
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger);
|
||||
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
|
||||
|
||||
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);
|
||||
|
@ -7,7 +7,8 @@ import java.util.List;
|
||||
|
||||
public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam, isBinary;
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer,
|
||||
secondaryParam, isBinary, isCollectionFormatMulti;
|
||||
public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue;
|
||||
public String jsonSchema;
|
||||
public boolean isEnum;
|
||||
@ -33,6 +34,7 @@ public class CodegenParameter {
|
||||
output.paramName = this.paramName;
|
||||
output.dataType = this.dataType;
|
||||
output.collectionFormat = this.collectionFormat;
|
||||
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
|
||||
output.description = this.description;
|
||||
output.baseType = this.baseType;
|
||||
output.isFormParam = this.isFormParam;
|
||||
|
@ -869,6 +869,10 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions) {
|
||||
return fromOperation(path, httpMethod, operation, definitions, null);
|
||||
}
|
||||
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
|
||||
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
|
||||
Set<String> imports = new HashSet<String>();
|
||||
op.vendorExtensions = operation.getVendorExtensions();
|
||||
@ -904,15 +908,32 @@ public class DefaultCodegen {
|
||||
op.summary = escapeText(operation.getSummary());
|
||||
op.notes = escapeText(operation.getDescription());
|
||||
op.tags = operation.getTags();
|
||||
op.hasConsumes = false;
|
||||
op.hasProduces = false;
|
||||
|
||||
if (operation.getConsumes() != null && operation.getConsumes().size() > 0) {
|
||||
List<String> consumes = new ArrayList<String>();
|
||||
if (operation.getConsumes() != null) {
|
||||
if (operation.getConsumes().size() > 0) {
|
||||
// use consumes defined in the operation
|
||||
consumes = operation.getConsumes();
|
||||
} else {
|
||||
// empty list, do nothing to override global setting
|
||||
}
|
||||
} else if (swagger != null && swagger.getConsumes() != null && swagger.getConsumes().size() > 0) {
|
||||
// use consumes defined globally
|
||||
consumes = swagger.getConsumes();
|
||||
LOGGER.debug("No consumes defined in operation. Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId);
|
||||
}
|
||||
|
||||
// if "consumes" is defined (per operation or using global definition)
|
||||
if (consumes != null && consumes.size() > 0) {
|
||||
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
|
||||
int count = 0;
|
||||
for (String key : operation.getConsumes()) {
|
||||
for (String key : consumes) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
mediaType.put("mediaType", key);
|
||||
count += 1;
|
||||
if (count < operation.getConsumes().size()) {
|
||||
if (count < consumes.size()) {
|
||||
mediaType.put("hasMore", "true");
|
||||
} else {
|
||||
mediaType.put("hasMore", null);
|
||||
@ -923,14 +944,29 @@ public class DefaultCodegen {
|
||||
op.hasConsumes = true;
|
||||
}
|
||||
|
||||
if (operation.getProduces() != null && operation.getProduces().size() > 0) {
|
||||
List<String> produces = new ArrayList<String>();
|
||||
if (operation.getProduces() != null) {
|
||||
if (operation.getProduces().size() > 0) {
|
||||
// use produces defined in the operation
|
||||
produces = operation.getProduces();
|
||||
} else {
|
||||
// empty list, do nothing to override global setting
|
||||
}
|
||||
} else if (swagger != null && swagger.getProduces() != null && swagger.getProduces().size() > 0) {
|
||||
// use produces defined globally
|
||||
produces = swagger.getProduces();
|
||||
LOGGER.debug("No produces defined in operation. Using global produces (" + swagger.getProduces() + ") for " + op.operationId);
|
||||
}
|
||||
|
||||
// if "produces" is defined (per operation or using global definition)
|
||||
if (produces != null && produces.size() > 0) {
|
||||
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
|
||||
int count = 0;
|
||||
for (String key : operation.getProduces()) {
|
||||
for (String key : produces) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
mediaType.put("mediaType", key);
|
||||
count += 1;
|
||||
if (count < operation.getProduces().size()) {
|
||||
if (count < produces.size()) {
|
||||
mediaType.put("hasMore", "true");
|
||||
} else {
|
||||
mediaType.put("hasMore", null);
|
||||
@ -1044,7 +1080,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
for (String i : imports) {
|
||||
if (!defaultIncludes.contains(i) && !languageSpecificPrimitives.contains(i)) {
|
||||
if (needToImport(i)) {
|
||||
op.imports.add(i);
|
||||
}
|
||||
}
|
||||
@ -1205,6 +1241,9 @@ public class DefaultCodegen {
|
||||
p._enum = model._enum;
|
||||
p.allowableValues = model.allowableValues;
|
||||
p.collectionFormat = collectionFormat;
|
||||
if(collectionFormat != null && collectionFormat.equals("multi")) {
|
||||
p.isCollectionFormatMulti = true;
|
||||
}
|
||||
p.paramName = toParamName(qp.getName());
|
||||
|
||||
if (model.complexType != null) {
|
||||
@ -1333,6 +1372,12 @@ public class DefaultCodegen {
|
||||
return secs;
|
||||
}
|
||||
|
||||
protected boolean needToImport(String type) {
|
||||
return !defaultIncludes.contains(type)
|
||||
&& !languageSpecificPrimitives.contains(type)
|
||||
&& type.indexOf(".") < 0;
|
||||
}
|
||||
|
||||
protected List<Map<String, Object>> toExamples(Map<String, Object> examples) {
|
||||
if (examples == null) {
|
||||
return null;
|
||||
@ -1436,7 +1481,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
private void addImport(CodegenModel m, String type) {
|
||||
if (type != null && !languageSpecificPrimitives.contains(type) && !defaultIncludes.contains(type)) {
|
||||
if (type != null && needToImport(type)) {
|
||||
m.imports.add(type);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.swagger.models.License;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Path;
|
||||
import io.swagger.models.SecurityRequirement;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.auth.OAuth2Definition;
|
||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
@ -470,22 +471,31 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (String tag : tags) {
|
||||
CodegenOperation co = null;
|
||||
try {
|
||||
co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions());
|
||||
co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions(), swagger);
|
||||
co.tags = new ArrayList<String>();
|
||||
co.tags.add(sanitizeTag(tag));
|
||||
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
||||
|
||||
List<Map<String, List<String>>> securities = operation.getSecurity();
|
||||
if (securities == null) {
|
||||
if (securities == null && swagger.getSecurity() != null) {
|
||||
securities = new ArrayList<Map<String, List<String>>>();
|
||||
for (SecurityRequirement sr : swagger.getSecurity()) {
|
||||
securities.add(sr.getRequirements());
|
||||
}
|
||||
}
|
||||
if (securities == null || securities.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Map<String, SecuritySchemeDefinition> authMethods = new HashMap<String, SecuritySchemeDefinition>();
|
||||
for (Map<String, List<String>> security : securities) {
|
||||
if (security.size() != 1) {
|
||||
//Not sure what to do
|
||||
continue;
|
||||
// NOTE: Use only the first security requirement for now.
|
||||
// See the "security" field of "Swagger Object":
|
||||
// https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object
|
||||
// "there is a logical OR between the security requirements"
|
||||
if (securities.size() > 1) {
|
||||
LOGGER.warn("More than 1 security requirements are found, using only the first one");
|
||||
}
|
||||
String securityName = security.keySet().iterator().next();
|
||||
Map<String, List<String>> security = securities.get(0);
|
||||
for (String securityName : security.keySet()) {
|
||||
SecuritySchemeDefinition securityDefinition = fromSecurity(securityName);
|
||||
if (securityDefinition != null) {
|
||||
if(securityDefinition instanceof OAuth2Definition) {
|
||||
@ -496,7 +506,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
oauth2Operation.setFlow(oauth2Definition.getFlow());
|
||||
oauth2Operation.setTokenUrl(oauth2Definition.getTokenUrl());
|
||||
oauth2Operation.setScopes(new HashMap<String, String>());
|
||||
for (String scope : security.values().iterator().next()) {
|
||||
for (String scope : security.get(securityName)) {
|
||||
if (oauth2Definition.getScopes().containsKey(scope)) {
|
||||
oauth2Operation.addScope(scope, oauth2Definition.getScopes().get(scope));
|
||||
}
|
||||
|
@ -106,11 +106,11 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
additionalProperties.put("clientPackage", clientPackage);
|
||||
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "ApiClient.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiClient.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll"));
|
||||
supportingFiles.add(new SupportingFile("RestSharp.dll", "bin", "RestSharp.dll"));
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
||||
@ -137,12 +137,11 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
|
||||
return outputFolder + File.separator + (sourceFolder + File.separator + apiPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + (sourceFolder + File.separator + modelPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,11 +108,11 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "ApiClient.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiClient.cs"));
|
||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
||||
(sourceFolder + File.separator + clientPackage).replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config"));
|
||||
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
@ -142,11 +142,11 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + File.separator + sourceFolder + File.separator + apiPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + File.separator + sourceFolder + File.separator + modelPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.LongProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
@ -37,6 +38,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
protected String localVariablePrefix = "";
|
||||
protected boolean fullJavaUtil = false;
|
||||
protected String javaUtilPrefix = "";
|
||||
protected Boolean serializableModel = false;
|
||||
|
||||
public JavaClientCodegen() {
|
||||
@ -81,6 +84,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
|
||||
cliOptions.add(new CliOption("fullJavaUtil", "whether to use fully qualified name for classes under java.util (default to false)"));
|
||||
|
||||
supportedLibraries.put("<default>", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
|
||||
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
|
||||
@ -149,13 +153,46 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) {
|
||||
this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY));
|
||||
}
|
||||
|
||||
// need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string
|
||||
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
|
||||
|
||||
if (additionalProperties.containsKey("fullJavaUtil")) {
|
||||
fullJavaUtil = Boolean.valueOf(additionalProperties.get("fullJavaUtil").toString());
|
||||
}
|
||||
if (fullJavaUtil) {
|
||||
javaUtilPrefix = "java.util.";
|
||||
}
|
||||
additionalProperties.put("fullJavaUtil", fullJavaUtil);
|
||||
additionalProperties.put("javaUtilPrefix", javaUtilPrefix);
|
||||
|
||||
if (fullJavaUtil) {
|
||||
typeMapping.put("array", "java.util.List");
|
||||
typeMapping.put("map", "java.util.Map");
|
||||
typeMapping.put("DateTime", "java.util.Date");
|
||||
typeMapping.remove("List");
|
||||
importMapping.remove("Date");
|
||||
importMapping.remove("Map");
|
||||
importMapping.remove("HashMap");
|
||||
importMapping.remove("Array");
|
||||
importMapping.remove("ArrayList");
|
||||
importMapping.remove("List");
|
||||
importMapping.remove("Set");
|
||||
importMapping.remove("DateTime");
|
||||
instantiationTypes.put("array", "java.util.ArrayList");
|
||||
instantiationTypes.put("map", "java.util.HashMap");
|
||||
}
|
||||
|
||||
this.sanitizeConfig();
|
||||
|
||||
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
|
||||
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
|
||||
|
||||
@ -177,12 +214,11 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if ("okhttp-gson".equals(getLibrary())) {
|
||||
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
|
||||
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
|
||||
// "build.gradle" is for development with Gradle
|
||||
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||
// "build.sbt" is for development with SBT
|
||||
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
|
||||
} else if ("retrofit".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("TypeRef.mustache", invokerFolder, "TypeRef.java"));
|
||||
}
|
||||
@ -294,10 +330,28 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toDefaultValue(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
final ArrayProperty ap = (ArrayProperty) p;
|
||||
return String.format("new ArrayList<%s>()", getTypeDeclaration(ap.getItems()));
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.ArrayList<%s>()";
|
||||
} else {
|
||||
pattern = "new ArrayList<%s>()";
|
||||
}
|
||||
return String.format(pattern, getTypeDeclaration(ap.getItems()));
|
||||
} else if (p instanceof MapProperty) {
|
||||
final MapProperty ap = (MapProperty) p;
|
||||
return String.format("new HashMap<String, %s>()", getTypeDeclaration(ap.getAdditionalProperties()));
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.HashMap<String, %s>()";
|
||||
} else {
|
||||
pattern = "new HashMap<String, %s>()";
|
||||
}
|
||||
return String.format(pattern, getTypeDeclaration(ap.getAdditionalProperties()));
|
||||
} else if (p instanceof LongProperty) {
|
||||
LongProperty dp = (LongProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
return dp.getDefault().toString()+"l";
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
}
|
||||
@ -308,7 +362,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
if (languageSpecificPrimitives.contains(type) || type.indexOf(".") >= 0) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
@ -418,6 +472,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return objs;
|
||||
}
|
||||
|
||||
protected boolean needToImport(String type) {
|
||||
return super.needToImport(type) && type.indexOf(".") < 0;
|
||||
}
|
||||
|
||||
private String findCommonPrefixOfVars(List<String> vars) {
|
||||
String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()]));
|
||||
// exclude trailing characters that should be part of a valid variable
|
||||
@ -426,7 +484,12 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
private String toEnumVarName(String value) {
|
||||
return value.replaceAll("\\W+", "_").toUpperCase();
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
|
||||
|
@ -22,10 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JavaInflectorServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.handler";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-inflector-server";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String title = "Swagger Inflector";
|
||||
|
||||
public JavaInflectorServerCodegen() {
|
||||
@ -35,6 +31,8 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen implements Cod
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
templateDir = "JavaInflector";
|
||||
invokerPackage = "io.swagger.handler";
|
||||
artifactId = "swagger-inflector-server";
|
||||
|
||||
apiPackage = System.getProperty("swagger.codegen.inflector.apipackage", "io.swagger.handler");
|
||||
modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "io.swagger.model");
|
||||
|
@ -16,16 +16,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.api";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-jaxrs-server";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String title = "Swagger Server";
|
||||
|
||||
public JaxRSServerCodegen() {
|
||||
super.processOpts();
|
||||
|
||||
sourceFolder = "src/gen/java";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-jaxrs-server";
|
||||
|
||||
outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "generated-code/javaJaxRS");
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
|
@ -15,13 +15,7 @@ import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SpringMVCServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.api";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-spring-mvc-server";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
protected String title = "Petstore Server";
|
||||
|
||||
protected String configPackage = "";
|
||||
|
||||
public SpringMVCServerCodegen() {
|
||||
@ -33,7 +27,8 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
configPackage = "io.swagger.configuration";
|
||||
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-spring-mvc-server";
|
||||
|
||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||
@ -201,4 +196,3 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.parameters.HeaderParameter;
|
||||
@ -256,7 +258,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions) {
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
|
||||
path = normalizePath(path);
|
||||
List<Parameter> parameters = operation.getParameters();
|
||||
parameters = Lists.newArrayList(Iterators.filter(parameters.iterator(), new Predicate<Parameter>() {
|
||||
@ -266,7 +268,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}));
|
||||
operation.setParameters(parameters);
|
||||
return super.fromOperation(path, httpMethod, operation, definitions);
|
||||
return super.fromOperation(path, httpMethod, operation, definitions, swagger);
|
||||
}
|
||||
|
||||
private static String normalizePath(String path) {
|
||||
|
@ -6,16 +6,12 @@ import {{invokerPackage}}.Configuration;
|
||||
import {{invokerPackage}}.Pair;
|
||||
import {{invokerPackage}}.TypeRef;
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.*;
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
@ -59,9 +55,9 @@ public class {{classname}} {
|
||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||
|
||||
// query params
|
||||
List<Pair> {{localVariablePrefix}}queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> {{localVariablePrefix}}headerParams = new HashMap<String, String>();
|
||||
Map<String, Object> {{localVariablePrefix}}formParams = new HashMap<String, Object>();
|
||||
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
|
||||
{{javaUtilPrefix}}Map<String, String> {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap<String, String>();
|
||||
{{javaUtilPrefix}}Map<String, Object> {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap<String, Object>();
|
||||
|
||||
{{#queryParams}}
|
||||
{{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
|
@ -0,0 +1,107 @@
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = '{{artifactId}}'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.0"
|
||||
jackson_version = "2.4.2"
|
||||
jersey_version = "1.18"
|
||||
jodatime_version = "2.3"
|
||||
junit_version = "4.8.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "com.sun.jersey:jersey-client:$jersey_version"
|
||||
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
# Uncomment to build for Android
|
||||
#target = android
|
@ -6,16 +6,12 @@ import {{invokerPackage}}.Configuration;
|
||||
import {{invokerPackage}}.Pair;
|
||||
import {{invokerPackage}}.TypeRef;
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.*;
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
@ -58,9 +54,9 @@ public class {{classname}} {
|
||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||
|
||||
// query params
|
||||
List<Pair> {{localVariablePrefix}}queryParams = new ArrayList<Pair>();
|
||||
Map<String, String> {{localVariablePrefix}}headerParams = new HashMap<String, String>();
|
||||
Map<String, Object> {{localVariablePrefix}}formParams = new HashMap<String, Object>();
|
||||
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
|
||||
{{javaUtilPrefix}}Map<String, String> {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap<String, String>();
|
||||
{{javaUtilPrefix}}Map<String, Object> {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap<String, Object>();
|
||||
|
||||
{{#queryParams}}
|
||||
{{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
|
@ -0,0 +1,107 @@
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = '{{artifactId}}'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.0"
|
||||
jackson_version = "2.4.2"
|
||||
jersey_version = "2.6"
|
||||
jodatime_version = "2.3"
|
||||
junit_version = "4.8.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
|
||||
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
@ -6,22 +6,17 @@ import {{invokerPackage}}.ApiException;
|
||||
import {{invokerPackage}}.Configuration;
|
||||
import {{invokerPackage}}.Pair;
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Type;
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.*;
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
@ -58,15 +53,15 @@ public class {{classname}} {
|
||||
String {{localVariablePrefix}}path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}
|
||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||
|
||||
List<Pair> {{localVariablePrefix}}queryParams = new ArrayList<Pair>();{{#queryParams}}
|
||||
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}queryParams = new {{javaUtilPrefix}}ArrayList<Pair>();{{#queryParams}}
|
||||
if ({{paramName}} != null)
|
||||
{{localVariablePrefix}}queryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));{{/queryParams}}
|
||||
|
||||
Map<String, String> {{localVariablePrefix}}headerParams = new HashMap<String, String>();{{#headerParams}}
|
||||
{{javaUtilPrefix}}Map<String, String> {{localVariablePrefix}}headerParams = new {{javaUtilPrefix}}HashMap<String, String>();{{#headerParams}}
|
||||
if ({{paramName}} != null)
|
||||
{{localVariablePrefix}}headerParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{/headerParams}}
|
||||
|
||||
Map<String, Object> {{localVariablePrefix}}formParams = new HashMap<String, Object>();{{#formParams}}
|
||||
{{javaUtilPrefix}}Map<String, Object> {{localVariablePrefix}}formParams = new {{javaUtilPrefix}}HashMap<String, Object>();{{#formParams}}
|
||||
if ({{paramName}} != null)
|
||||
{{localVariablePrefix}}formParams.put("{{baseName}}", {{paramName}});{{/formParams}}
|
||||
|
||||
|
@ -1,11 +1,89 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = '{{artifactId}}'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -15,17 +93,3 @@ dependencies {
|
||||
compile 'com.brsanthu:migbase64:2.2'
|
||||
testCompile 'junit:junit:4.8.1'
|
||||
}
|
||||
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = '{{artifactId}}'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
@ -49,16 +49,16 @@ public class ApiClient {
|
||||
for(String authName : authNames) {
|
||||
if (apiAuthorizations.containsKey(authName)) {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" already in api authorizations");
|
||||
}
|
||||
Interceptor auth;{{#authMethods}}
|
||||
}{{#authMethods}}
|
||||
Interceptor auth;
|
||||
if (authName == "{{name}}") { {{#isBasic}}
|
||||
auth = new HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
|
||||
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
|
||||
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");{{/isOAuth}}
|
||||
} else {{/authMethods}}{
|
||||
} else {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
apiAuthorizations.put(authName, auth);
|
||||
apiAuthorizations.put(authName, auth);{{/authMethods}}
|
||||
}
|
||||
addAuthsToOkClient(okClient);
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFormats {
|
||||
|
||||
public static class CSVParams {
|
||||
|
||||
protected List<String> params;
|
||||
|
||||
public CSVParams() {
|
||||
}
|
||||
|
||||
public CSVParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public CSVParams(String... params) {
|
||||
this.params = Arrays.asList(params);
|
||||
}
|
||||
|
||||
public List<String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SSVParams extends CSVParams {
|
||||
|
||||
public SSVParams() {
|
||||
}
|
||||
|
||||
public SSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public SSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), " ");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TSVParams extends CSVParams {
|
||||
|
||||
public TSVParams() {
|
||||
}
|
||||
|
||||
public TSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public TSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join( params.toArray(new String[0]), "\t");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PIPESParams extends CSVParams {
|
||||
|
||||
public PIPESParams() {
|
||||
}
|
||||
|
||||
public PIPESParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public PIPESParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), "|");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,18 @@
|
||||
package {{package}};
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
import {{invokerPackage}}.CollectionFormats.*;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.http.*;
|
||||
import retrofit.mime.*;
|
||||
import java.util.*;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{^fullJavaUtil}}
|
||||
import java.util.*;
|
||||
{{/fullJavaUtil}}
|
||||
|
||||
{{#operations}}
|
||||
public interface {{classname}} {
|
||||
{{#operation}}
|
||||
|
@ -0,0 +1,103 @@
|
||||
group = '{{groupId}}'
|
||||
version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = '{{artifactId}}'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
okhttp_version = "2.3.0"
|
||||
oltu_version = "1.0.0"
|
||||
retrofit_version = "1.9.0"
|
||||
swagger_annotations_version = "1.5.0"
|
||||
junit_version = "4.12"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.squareup.okhttp:okhttp:$okhttp_version"
|
||||
compile "com.squareup.retrofit:retrofit:$retrofit_version"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
@ -1 +1 @@
|
||||
{{#isQueryParam}}@Query("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
||||
{{#isQueryParam}}@Query("{{baseName}}") {{#collectionFormat}}{{#isCollectionFormatMulti}}{{{dataType}}}{{/isCollectionFormatMulti}}{{^isCollectionFormatMulti}}{{{collectionFormat.toUpperCase}}}Params{{/isCollectionFormatMulti}}{{/collectionFormat}}{{^collectionFormat}}{{{dataType}}}{{/collectionFormat}} {{paramName}}{{/isQueryParam}}
|
@ -0,0 +1 @@
|
||||
rootProject.name = "{{artifactId}}"
|
@ -3,7 +3,7 @@
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
{{#operations}}
|
||||
module {{package}} {
|
||||
namespace {{package}} {
|
||||
'use strict';
|
||||
|
||||
{{#description}}
|
||||
@ -16,7 +16,7 @@ module {{package}} {
|
||||
|
||||
static $inject: string[] = ['$http', '$httpParamSerializer'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) {
|
||||
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (d: any) => any) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -24,16 +24,16 @@ module {{package}} {
|
||||
{{#operation}}
|
||||
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
|
||||
var path = this.basePath + '{{path}}';
|
||||
let path = this.basePath + '{{path}}';
|
||||
|
||||
{{#pathParams}}
|
||||
path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}}));
|
||||
|
||||
{{/pathParams}}
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = {};
|
||||
{{#hasFormParams}}
|
||||
var formParams: any = {};
|
||||
let formParams: any = {};
|
||||
|
||||
{{/hasFormParams}}
|
||||
{{#allParams}}
|
||||
@ -63,7 +63,7 @@ module {{package}} {
|
||||
formParams['{{baseName}}'] = {{paramName}};
|
||||
|
||||
{{/formParams}}
|
||||
var httpRequestParams: any = {
|
||||
let httpRequestParams: any = {
|
||||
method: '{{httpMethod}}',
|
||||
url: path,
|
||||
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
|
||||
@ -76,7 +76,7 @@ module {{package}} {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
for (let k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module {{package}} {
|
||||
namespace {{package}} {
|
||||
'use strict';
|
||||
|
||||
{{#models}}
|
||||
@ -10,7 +10,7 @@ module {{package}} {
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/description}}
|
||||
export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||
{{#vars}}
|
||||
|
||||
{{#description}}
|
||||
@ -23,7 +23,7 @@ module {{package}} {
|
||||
}
|
||||
|
||||
{{#hasEnums}}
|
||||
export module {{classname}} {
|
||||
export namespace {{classname}} {
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
|
@ -27,7 +27,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||
}
|
||||
|
||||
{{#hasEnums}}
|
||||
export module {{classname}} {
|
||||
export namespace {{classname}} {
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}}
|
||||
@ -157,15 +157,15 @@ export class {{classname}} {
|
||||
{{#operation}}
|
||||
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> {
|
||||
var path = this.url + this.basePath + '{{path}}';
|
||||
let path = this.url + this.basePath + '{{path}}';
|
||||
|
||||
{{#pathParams}}
|
||||
path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}}));
|
||||
|
||||
{{/pathParams}}
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
var formParams: any = {};
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = {};
|
||||
let formParams: any = {};
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify required parameter '{{paramName}}' is set
|
||||
@ -183,7 +183,7 @@ export class {{classname}} {
|
||||
headerParams['{{baseName}}'] = {{paramName}};
|
||||
|
||||
{{/headerParams}}
|
||||
var useFormData = false;
|
||||
let useFormData = false;
|
||||
|
||||
{{#formParams}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
@ -194,9 +194,9 @@ export class {{classname}} {
|
||||
{{/isFile}}
|
||||
|
||||
{{/formParams}}
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>();
|
||||
let deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>();
|
||||
|
||||
var requestOptions: request.Options = {
|
||||
let requestOptions: request.Options = {
|
||||
method: '{{httpMethod}}',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
|
@ -165,6 +165,12 @@ class ApiClient
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
// disable SSL verification, if needed
|
||||
if ($this->config->getSSLVerification() == false) {
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
|
||||
if (! empty($queryParams)) {
|
||||
$url = ($url . '?' . http_build_query($queryParams));
|
||||
}
|
||||
|
@ -126,6 +126,15 @@ class Configuration
|
||||
*/
|
||||
protected $tempFolderPath;
|
||||
|
||||
/**
|
||||
* Indicates if SSL verification should be enabled or disabled.
|
||||
*
|
||||
* This is useful if the host uses a self-signed SSL certificate.
|
||||
*
|
||||
* @var boolean True if the certificate should be validated, false otherwise.
|
||||
*/
|
||||
protected $sslVerification = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -418,6 +427,29 @@ class Configuration
|
||||
return $this->tempFolderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if SSL verification should be enabled or disabled
|
||||
*
|
||||
* @param boolean $sslVerification True if the certificate should be validated, false otherwise
|
||||
*
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setSSLVerification($sslVerification)
|
||||
{
|
||||
$this->sslVerification = $sslVerification;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if SSL verification should be enabled or disabled
|
||||
*
|
||||
* @return boolean True if the certificate should be validated, false otherwise
|
||||
*/
|
||||
public function getSSLVerification()
|
||||
{
|
||||
return $this->sslVerification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default configuration instance
|
||||
*
|
||||
|
@ -138,7 +138,7 @@ module {{moduleName}}
|
||||
end
|
||||
|
||||
def base_url
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||
URI.encode(url)
|
||||
end
|
||||
|
||||
|
@ -139,4 +139,52 @@ public class CodegenTest {
|
||||
Assert.assertTrue(op.bodyParam.isBinary);
|
||||
Assert.assertTrue(op.responses.get(0).isBinary);
|
||||
}
|
||||
|
||||
@Test(description = "use operation consumes and produces")
|
||||
public void localConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
|
||||
|
||||
Assert.assertTrue(op.hasConsumes);
|
||||
Assert.assertEquals(op.consumes.size(), 1);
|
||||
Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/json");
|
||||
Assert.assertTrue(op.hasProduces);
|
||||
Assert.assertEquals(op.produces.size(), 1);
|
||||
Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/json");
|
||||
}
|
||||
|
||||
@Test(description = "use spec consumes and produces")
|
||||
public void globalConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/globalConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
|
||||
|
||||
Assert.assertTrue(op.hasConsumes);
|
||||
Assert.assertEquals(op.consumes.size(), 1);
|
||||
Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/global_consumes");
|
||||
Assert.assertTrue(op.hasProduces);
|
||||
Assert.assertEquals(op.produces.size(), 1);
|
||||
Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/global_produces");
|
||||
}
|
||||
|
||||
@Test(description = "use operation consumes and produces (reset in operation with empty array)")
|
||||
public void localResetConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localResetConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
|
||||
|
||||
Assert.assertNotNull(op);
|
||||
Assert.assertFalse(op.hasConsumes);
|
||||
Assert.assertNull(op.consumes);
|
||||
Assert.assertFalse(op.hasProduces);
|
||||
Assert.assertNull(op.produces);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,14 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests for DefaultGenerator logic
|
||||
@ -44,6 +47,102 @@ public class DefaultGeneratorTest {
|
||||
folder.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurityWithoutGlobal() throws Exception {
|
||||
final Swagger swagger = new SwaggerParser().read("src/test/resources/2_0/petstore.json");
|
||||
CodegenConfig codegenConfig = new JavaClientCodegen();
|
||||
|
||||
ClientOptInput clientOptInput = new ClientOptInput().opts(new ClientOpts()).swagger(swagger).config(codegenConfig);
|
||||
|
||||
DefaultGenerator gen = new DefaultGenerator();
|
||||
gen.opts(clientOptInput);
|
||||
Map<String, List<CodegenOperation>> paths = gen.processPaths(swagger.getPaths());
|
||||
|
||||
CodegenSecurity apiKey, petstoreAuth;
|
||||
|
||||
// security of "getPetById": api_key
|
||||
CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById");
|
||||
assertEquals(getPetById.authMethods.size(), 1);
|
||||
apiKey = getPetById.authMethods.iterator().next();
|
||||
assertEquals(apiKey.name, "api_key");
|
||||
assertEquals(apiKey.type, "apiKey");
|
||||
|
||||
// security of "updatePetWithForm": petstore_auth
|
||||
CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm");
|
||||
assertEquals(updatePetWithForm.authMethods.size(), 1);
|
||||
petstoreAuth = updatePetWithForm.authMethods.iterator().next();
|
||||
assertEquals(petstoreAuth.name, "petstore_auth");
|
||||
assertEquals(petstoreAuth.type, "oauth2");
|
||||
|
||||
// security of "loginUser": null (no global security either)
|
||||
CodegenOperation loginUser = findCodegenOperationByOperationId(paths, "loginUser");
|
||||
assertNull(loginUser.authMethods);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurityWithGlobal() throws Exception {
|
||||
final Swagger swagger = new SwaggerParser().read("src/test/resources/2_0/globalSecurity.json");
|
||||
CodegenConfig codegenConfig = new JavaClientCodegen();
|
||||
|
||||
ClientOptInput clientOptInput = new ClientOptInput().opts(new ClientOpts()).swagger(swagger).config(codegenConfig);
|
||||
|
||||
DefaultGenerator gen = new DefaultGenerator();
|
||||
gen.opts(clientOptInput);
|
||||
Map<String, List<CodegenOperation>> paths = gen.processPaths(swagger.getPaths());
|
||||
|
||||
CodegenSecurity cs, apiKey, apiKey2, petstoreAuth;
|
||||
|
||||
// security of "getPetById": api_key
|
||||
CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById");
|
||||
assertEquals(getPetById.authMethods.size(), 1);
|
||||
apiKey = getPetById.authMethods.iterator().next();
|
||||
assertEquals(apiKey.name, "api_key");
|
||||
assertEquals(apiKey.type, "apiKey");
|
||||
|
||||
// security of "updatePetWithForm": petstore_auth
|
||||
CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm");
|
||||
assertEquals(updatePetWithForm.authMethods.size(), 1);
|
||||
petstoreAuth = updatePetWithForm.authMethods.iterator().next();
|
||||
assertEquals(petstoreAuth.name, "petstore_auth");
|
||||
assertEquals(petstoreAuth.type, "oauth2");
|
||||
|
||||
// security of "loginUser": api_key, petstore_auth (from global security)
|
||||
CodegenOperation loginUser = findCodegenOperationByOperationId(paths, "loginUser");
|
||||
assertEquals(loginUser.authMethods.size(), 2);
|
||||
cs = loginUser.authMethods.get(0);
|
||||
if ("api_key".equals(cs.name)) {
|
||||
apiKey = cs;
|
||||
petstoreAuth = loginUser.authMethods.get(1);
|
||||
} else {
|
||||
petstoreAuth = cs;
|
||||
apiKey = loginUser.authMethods.get(1);
|
||||
}
|
||||
assertEquals(apiKey.name, "api_key");
|
||||
assertEquals(apiKey.type, "apiKey");
|
||||
assertEquals(petstoreAuth.name, "petstore_auth");
|
||||
assertEquals(petstoreAuth.type, "oauth2");
|
||||
|
||||
// security of "logoutUser": null (override global security)
|
||||
CodegenOperation logoutUser = findCodegenOperationByOperationId(paths, "logoutUser");
|
||||
assertNull(logoutUser.authMethods);
|
||||
|
||||
// security of "getUserByName": api_key, api_key2 (override global security)
|
||||
CodegenOperation getUserByName = findCodegenOperationByOperationId(paths, "getUserByName");
|
||||
assertEquals(getUserByName.authMethods.size(), 2);
|
||||
cs = getUserByName.authMethods.get(0);
|
||||
if ("api_key".equals(cs.name)) {
|
||||
apiKey = cs;
|
||||
apiKey2 = getUserByName.authMethods.get(1);
|
||||
} else {
|
||||
apiKey2 = cs;
|
||||
apiKey = getUserByName.authMethods.get(1);
|
||||
}
|
||||
assertEquals(apiKey.name, "api_key");
|
||||
assertEquals(apiKey.type, "apiKey");
|
||||
assertEquals(apiKey2.name, "api_key2");
|
||||
assertEquals(apiKey2.type, "apiKey");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipOverwrite() throws Exception {
|
||||
final File output = folder.getRoot();
|
||||
@ -89,4 +188,15 @@ public class DefaultGeneratorTest {
|
||||
out.close();
|
||||
}
|
||||
|
||||
private CodegenOperation findCodegenOperationByOperationId(Map<String, List<CodegenOperation>> paths, String operationId) {
|
||||
for (List<CodegenOperation> ops : paths.values()) {
|
||||
for (CodegenOperation co : ops) {
|
||||
if (operationId.equals(co.operationId)) {
|
||||
return co;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,130 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Spec for testing global consumes and produces",
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"email": "apiteam@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/v2",
|
||||
"consumes": ["application/global_consumes"],
|
||||
"produces": ["application/global_produces"],
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
"/tests/localConsumesAndProduces": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"tests"
|
||||
],
|
||||
"summary": "Operation with local consumes and produces",
|
||||
"description": "",
|
||||
"operationId": "localConsumesAndProduces",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation. Returning a simple int.",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/tests/globalConsumesAndProduces": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"tests"
|
||||
],
|
||||
"summary": "Operation with global consumes and produces",
|
||||
"description": "",
|
||||
"operationId": "globalConsumesAndProduces",
|
||||
"parameters": [
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation. Returning a simple int.",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/tests/localResetConsumesAndProduces": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"tests"
|
||||
],
|
||||
"summary": "Operation with local consumes and produces set to empty (reset)",
|
||||
"description": "",
|
||||
"operationId": "localResetConsumesAndProduces",
|
||||
"parameters": [
|
||||
],
|
||||
"consumes": [],
|
||||
"produces": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation. Returning a simple int.",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"api_key": {
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"in": "header"
|
||||
},
|
||||
"petstore_auth": {
|
||||
"type": "oauth2",
|
||||
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
|
||||
"flow": "implicit",
|
||||
"scopes": {
|
||||
"write:pets": "modify pets in your account",
|
||||
"read:pets": "read your pets"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"CustomModel": {
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "doggie"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,998 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"email": "apiteam@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/v2",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
"/pet": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Add a new pet to the store",
|
||||
"description": "",
|
||||
"operationId": "addPet",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Update an existing pet",
|
||||
"description": "",
|
||||
"operationId": "updatePet",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Validation exception"
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/findByStatus": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Finds Pets by status",
|
||||
"description": "Multiple status values can be provided with comma seperated strings",
|
||||
"operationId": "findPetsByStatus",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"description": "Status values that need to be considered for filter",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"default": "available"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid status value"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/findByTags": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Finds Pets by tags",
|
||||
"description": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
|
||||
"operationId": "findPetsByTags",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "Tags to filter by",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid tag value"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/{petId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Find pet by ID",
|
||||
"description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
|
||||
"operationId": "getPetById",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
},
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Updates a pet in the store with form data",
|
||||
"description": "",
|
||||
"operationId": "updatePetWithForm",
|
||||
"consumes": [
|
||||
"application/x-www-form-urlencoded"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be updated",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"in": "formData",
|
||||
"description": "Updated name of the pet",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"in": "formData",
|
||||
"description": "Updated status of the pet",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Deletes a pet",
|
||||
"description": "",
|
||||
"operationId": "deletePet",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "api_key",
|
||||
"in": "header",
|
||||
"description": "",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "Pet id to delete",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid pet value"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/{petId}/uploadImage": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "uploads an image",
|
||||
"description": "",
|
||||
"operationId": "uploadFile",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet to update",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"name": "additionalMetadata",
|
||||
"in": "formData",
|
||||
"description": "Additional data to pass to server",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"description": "file to upload",
|
||||
"required": false,
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/store/inventory": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Returns pet inventories by status",
|
||||
"description": "Returns a map of status codes to quantities",
|
||||
"operationId": "getInventory",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/store/order": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Place an order for a pet",
|
||||
"description": "",
|
||||
"operationId": "placeOrder",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "order placed for purchasing the pet",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/order/{orderId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Find purchase order by ID",
|
||||
"description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
"operationId": "getOrderById",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
},
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Delete purchase order by ID",
|
||||
"description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
"operationId": "deleteOrder",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of the order that needs to be deleted",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Create user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "createUser",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Created user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithArray": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Creates list of users with given input array",
|
||||
"description": "",
|
||||
"operationId": "createUsersWithArrayInput",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithList": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Creates list of users with given input array",
|
||||
"description": "",
|
||||
"operationId": "createUsersWithListInput",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/login": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Logs user into the system",
|
||||
"description": "",
|
||||
"operationId": "loginUser",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "query",
|
||||
"description": "The user name for login",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"in": "query",
|
||||
"description": "The password for login in clear text",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username/password supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/logout": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Logs out current logged in user session",
|
||||
"description": "",
|
||||
"operationId": "logoutUser",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
},
|
||||
"security": []
|
||||
}
|
||||
},
|
||||
"/user/{username}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Get user by user name",
|
||||
"description": "",
|
||||
"operationId": "getUserByName",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "The name that needs to be fetched. Use user1 for testing. ",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/User"
|
||||
},
|
||||
"examples": {
|
||||
"application/json": {
|
||||
"id": 1,
|
||||
"username": "johnp",
|
||||
"firstName": "John",
|
||||
"lastName": "Public",
|
||||
"email": "johnp@swagger.io",
|
||||
"password": "-secret-",
|
||||
"phone": "0123456789",
|
||||
"userStatus": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username supplied"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": [],
|
||||
"api_key2": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Updated user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "updateUser",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "name that need to be deleted",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Updated user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid user supplied"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "Delete user",
|
||||
"description": "This can only be done by the logged in user.",
|
||||
"operationId": "deleteUser",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "The name that needs to be deleted",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"api_key": {
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"in": "header"
|
||||
},
|
||||
"api_key2": {
|
||||
"type": "apiKey",
|
||||
"name": "api_key2",
|
||||
"in": "query"
|
||||
},
|
||||
"petstore_auth": {
|
||||
"type": "oauth2",
|
||||
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
|
||||
"flow": "implicit",
|
||||
"scopes": {
|
||||
"write:pets": "modify pets in your account",
|
||||
"read:pets": "read your pets"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": [],
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
],
|
||||
"definitions": {
|
||||
"User": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"userStatus": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": "User Status"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "User"
|
||||
}
|
||||
},
|
||||
"Category": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Category"
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"required": [
|
||||
"name",
|
||||
"photoUrls"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/definitions/Category"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "doggie"
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "photoUrl",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "tag",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"$ref": "#/definitions/Tag"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "pet status in the store",
|
||||
"enum": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Pet"
|
||||
}
|
||||
},
|
||||
"Tag": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Tag"
|
||||
}
|
||||
},
|
||||
"Order": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"petId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"shipDate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "Order Status",
|
||||
"enum": [
|
||||
"placed",
|
||||
"approved",
|
||||
"delivered"
|
||||
]
|
||||
},
|
||||
"complete": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
pom.xml
1
pom.xml
@ -426,6 +426,7 @@
|
||||
<module>samples/client/petstore/java/default</module>
|
||||
<module>samples/client/petstore/java/jersey2</module>
|
||||
<module>samples/client/petstore/java/okhttp-gson</module>
|
||||
<module>samples/client/petstore/java/retrofit</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/server/petstore/spring-mvc</module>
|
||||
<!--module>samples/client/petstore/objc</module-->
|
||||
|
107
samples/client/petstore/java/default/build.gradle
Normal file
107
samples/client/petstore/java/default/build.gradle
Normal file
@ -0,0 +1,107 @@
|
||||
group = 'io.swagger'
|
||||
version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-java-client'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.0"
|
||||
jackson_version = "2.4.2"
|
||||
jersey_version = "1.18"
|
||||
jodatime_version = "2.3"
|
||||
junit_version = "4.8.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "com.sun.jersey:jersey-client:$jersey_version"
|
||||
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
2
samples/client/petstore/java/default/gradle.properties
Normal file
2
samples/client/petstore/java/default/gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# Uncomment to build for Android
|
||||
#target = android
|
1
samples/client/petstore/java/default/settings.gradle
Normal file
1
samples/client/petstore/java/default/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "swagger-java-client"
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-01T23:05:28.119+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-16T10:32:51.872+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -272,7 +266,7 @@ public class PetApi {
|
||||
};
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
|
||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
|
||||
|
||||
|
||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-01T23:05:28.119+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-01T23:05:28.119+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-01T23:05:28.119+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -2,8 +2,8 @@ package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import io.swagger.client.model.Category;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-01T23:05:28.119+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:27.235+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
|
107
samples/client/petstore/java/jersey2/build.gradle
Normal file
107
samples/client/petstore/java/jersey2/build.gradle
Normal file
@ -0,0 +1,107 @@
|
||||
group = 'io.swagger'
|
||||
version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-petstore-jersey2'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.0"
|
||||
jackson_version = "2.4.2"
|
||||
jersey_version = "2.6"
|
||||
jodatime_version = "2.3"
|
||||
junit_version = "4.8.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.glassfish.jersey.core:jersey-client:$jersey_version"
|
||||
compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
|
||||
compile "joda-time:joda-time:$jodatime_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
2
samples/client/petstore/java/jersey2/gradle.properties
Normal file
2
samples/client/petstore/java/jersey2/gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# Uncomment to build for Android
|
||||
#target = android
|
1
samples/client/petstore/java/jersey2/settings.gradle
Normal file
1
samples/client/petstore/java/jersey2/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "swagger-petstore-jersey2"
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-16T10:40:45.419+08:00")
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
@ -243,7 +237,7 @@ public class PetApi {
|
||||
};
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth", "api_key" };
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
|
||||
|
||||
TypeRef returnType = new TypeRef<Pet>() {};
|
||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00")
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
import io.swagger.client.TypeRef;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00")
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -19,7 +19,9 @@ public class Order {
|
||||
private Date shipDate = null;
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"), APPROVED("approved"), DELIVERED("delivered");
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-09T21:30:19.416+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -22,7 +22,9 @@ public class Pet {
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"), PENDING("pending"), SOLD("sold");
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -1,11 +1,89 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
group = 'io.swagger'
|
||||
version = '1.0.0'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-petstore-okhttp-gson'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -15,17 +93,3 @@ dependencies {
|
||||
compile 'com.brsanthu:migbase64:2.2'
|
||||
testCompile 'junit:junit:4.8.1'
|
||||
}
|
||||
|
||||
group = 'io.swagger'
|
||||
version = '1.0.0'
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-petstore-okhttp-gson'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
# Uncomment to build for Android
|
||||
#target = android
|
1
samples/client/petstore/java/okhttp-gson/settings.gradle
Normal file
1
samples/client/petstore/java/okhttp-gson/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "swagger-petstore-okhttp-gson"
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class PetApi {
|
||||
private ApiClient apiClient;
|
||||
@ -297,7 +290,7 @@ public class PetApi {
|
||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
headerParams.put("Content-Type", contentType);
|
||||
|
||||
String[] authNames = new String[] { "petstore_auth", "api_key" };
|
||||
String[] authNames = new String[] { "api_key" };
|
||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class StoreApi {
|
||||
private ApiClient apiClient;
|
||||
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
||||
import io.swagger.client.Configuration;
|
||||
import io.swagger.client.Pair;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.squareup.okhttp.Call;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class UserApi {
|
||||
private ApiClient apiClient;
|
||||
|
103
samples/client/petstore/java/retrofit/build.gradle
Normal file
103
samples/client/petstore/java/retrofit/build.gradle
Normal file
@ -0,0 +1,103 @@
|
||||
group = 'io.swagger'
|
||||
version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.2'
|
||||
classpath 'com.github.dcendents:android-maven-plugin:1.2'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.0'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 22
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-petstore-retrofit'
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
okhttp_version = "2.3.0"
|
||||
oltu_version = "1.0.0"
|
||||
retrofit_version = "1.9.0"
|
||||
swagger_annotations_version = "1.5.0"
|
||||
junit_version = "4.12"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.squareup.okhttp:okhttp:$okhttp_version"
|
||||
compile "com.squareup.retrofit:retrofit:$retrofit_version"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
2
samples/client/petstore/java/retrofit/gradle.properties
Normal file
2
samples/client/petstore/java/retrofit/gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# Uncomment to build for Android
|
||||
#target = android
|
1
samples/client/petstore/java/retrofit/settings.gradle
Normal file
1
samples/client/petstore/java/retrofit/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "swagger-petstore-retrofit"
|
@ -0,0 +1,95 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFormats {
|
||||
|
||||
public static class CSVParams {
|
||||
|
||||
protected List<String> params;
|
||||
|
||||
public CSVParams() {
|
||||
}
|
||||
|
||||
public CSVParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public CSVParams(String... params) {
|
||||
this.params = Arrays.asList(params);
|
||||
}
|
||||
|
||||
public List<String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SSVParams extends CSVParams {
|
||||
|
||||
public SSVParams() {
|
||||
}
|
||||
|
||||
public SSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public SSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), " ");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TSVParams extends CSVParams {
|
||||
|
||||
public TSVParams() {
|
||||
}
|
||||
|
||||
public TSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public TSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join( params.toArray(new String[0]), "\t");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PIPESParams extends CSVParams {
|
||||
|
||||
public PIPESParams() {
|
||||
}
|
||||
|
||||
public PIPESParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public PIPESParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), "|");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-18T14:07:38.326+02:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-11T00:10:38.251+02:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -1,15 +1,16 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.CollectionFormats.*;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.http.*;
|
||||
import retrofit.mime.*;
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface PetApi {
|
||||
|
||||
/**
|
||||
|
@ -1,15 +1,16 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.CollectionFormats.*;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.http.*;
|
||||
import retrofit.mime.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface StoreApi {
|
||||
|
||||
/**
|
||||
|
@ -1,15 +1,16 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.CollectionFormats.*;
|
||||
|
||||
import retrofit.Callback;
|
||||
import retrofit.http.*;
|
||||
import retrofit.mime.*;
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface UserApi {
|
||||
|
||||
/**
|
||||
|
@ -237,7 +237,7 @@ module Petstore
|
||||
post_body = nil
|
||||
|
||||
|
||||
auth_names = ['petstore_auth', 'api_key']
|
||||
auth_names = ['api_key']
|
||||
result = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
|
@ -138,7 +138,7 @@ module Petstore
|
||||
end
|
||||
|
||||
def base_url
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||
URI.encode(url)
|
||||
end
|
||||
|
||||
|
25
samples/client/petstore/ruby/spec/configuration_spec.rb
Normal file
25
samples/client/petstore/ruby/spec/configuration_spec.rb
Normal file
@ -0,0 +1,25 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Petstore::Configuration do
|
||||
let(:config) { Petstore::Configuration.instance }
|
||||
|
||||
before(:each) do
|
||||
Petstore.configure do |c|
|
||||
c.host = 'petstore.swagger.io'
|
||||
c.base_path = 'v2'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#base_url' do
|
||||
it 'should have the default value' do
|
||||
config.base_url.should == 'http://petstore.swagger.io/v2'
|
||||
end
|
||||
|
||||
it 'should remove trailing slashes' do
|
||||
[nil, '', '/', '//'].each do |base_path|
|
||||
config.base_path = base_path
|
||||
config.base_url.should == 'http://petstore.swagger.io'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user