forked from loafle/openapi-generator-original
Merge branch 'develop_2.0' into library-template-jersey2
Conflicts: modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache
This commit is contained in:
commit
595c01c537
@ -30,6 +30,23 @@ public class CodegenOperation {
|
|||||||
public List<Map<String, String>> examples;
|
public List<Map<String, String>> examples;
|
||||||
public ExternalDocs externalDocs;
|
public ExternalDocs externalDocs;
|
||||||
|
|
||||||
|
private boolean nonempty(List<CodegenParameter> params)
|
||||||
|
{
|
||||||
|
return params != null && params.size() > 0;
|
||||||
|
}
|
||||||
|
public boolean getHasBodyParam() {
|
||||||
|
return nonempty(bodyParams);
|
||||||
|
}
|
||||||
|
public boolean getHasQueryParams() {
|
||||||
|
return nonempty(bodyParams);
|
||||||
|
}
|
||||||
|
public boolean getHasHeaderParams() {
|
||||||
|
return nonempty(bodyParams);
|
||||||
|
}
|
||||||
|
public boolean getHasPathParams() {
|
||||||
|
return nonempty(bodyParams);
|
||||||
|
}
|
||||||
|
|
||||||
// legacy support
|
// legacy support
|
||||||
public String nickname;
|
public String nickname;
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,9 @@ public class DefaultCodegen {
|
|||||||
if (np.getMaximum() != null) {
|
if (np.getMaximum() != null) {
|
||||||
allowableValues.put("max", np.getMaximum());
|
allowableValues.put("max", np.getMaximum());
|
||||||
}
|
}
|
||||||
property.allowableValues = allowableValues;
|
if(allowableValues.size() > 0) {
|
||||||
|
property.allowableValues = allowableValues;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof StringProperty) {
|
if (p instanceof StringProperty) {
|
||||||
|
@ -17,6 +17,7 @@ import io.swagger.models.parameters.Parameter;
|
|||||||
import io.swagger.util.Json;
|
import io.swagger.util.Json;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -63,6 +64,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
try {
|
try {
|
||||||
config.processOpts();
|
config.processOpts();
|
||||||
|
|
||||||
|
config.additionalProperties().put("generatedDate", DateTime.now().toString());
|
||||||
|
config.additionalProperties().put("generatorClass", config.getClass().toString());
|
||||||
|
|
||||||
if (swagger.getInfo() != null) {
|
if (swagger.getInfo() != null) {
|
||||||
Info info = swagger.getInfo();
|
Info info = swagger.getInfo();
|
||||||
if (info.getTitle() != null) {
|
if (info.getTitle() != null) {
|
||||||
@ -189,7 +194,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String templateName : config.apiTemplateFiles().keySet()) {
|
for (String templateName : config.apiTemplateFiles().keySet()) {
|
||||||
|
|
||||||
String filename = config.apiFilename(templateName, tag);
|
String filename = config.apiFilename(templateName, tag);
|
||||||
if (!config.shouldOverwrite(filename)) {
|
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
if (additionalProperties.containsKey("invokerPackage")) {
|
if (additionalProperties.containsKey("invokerPackage")) {
|
||||||
this.setInvokerPackage((String) additionalProperties.get("invokerPackage"));
|
this.setInvokerPackage((String) additionalProperties.get("invokerPackage"));
|
||||||
} else {
|
} else {
|
||||||
@ -134,6 +134,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix"));
|
this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sanitizeConfig();
|
||||||
|
|
||||||
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
|
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
|
||||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||||
@ -151,7 +153,26 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
|
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sanitizeConfig() {
|
||||||
|
// Sanitize any config options here. We also have to update the additionalProperties because
|
||||||
|
// the whole additionalProperties object is injected into the main object passed to the mustache layer
|
||||||
|
|
||||||
|
this.setApiPackage(sanitizePackageName(apiPackage));
|
||||||
|
if (additionalProperties.containsKey("apiPackage")) {
|
||||||
|
this.additionalProperties.put("apiPackage", apiPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setModelPackage(sanitizePackageName(modelPackage));
|
||||||
|
if (additionalProperties.containsKey("modelPackage")) {
|
||||||
|
this.additionalProperties.put("modelPackage", modelPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setInvokerPackage(sanitizePackageName(invokerPackage));
|
||||||
|
if (additionalProperties.containsKey("invokerPackage")) {
|
||||||
|
this.additionalProperties.put("invokerPackage", invokerPackage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeReservedWord(String name) {
|
public String escapeReservedWord(String name) {
|
||||||
return "_" + name;
|
return "_" + name;
|
||||||
@ -347,4 +368,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public void setLocalVariablePrefix(String localVariablePrefix) {
|
public void setLocalVariablePrefix(String localVariablePrefix) {
|
||||||
this.localVariablePrefix = localVariablePrefix;
|
this.localVariablePrefix = localVariablePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String sanitizePackageName(String packageName) {
|
||||||
|
packageName = packageName.trim();
|
||||||
|
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
|
||||||
|
if(Strings.isNullOrEmpty(packageName)) {
|
||||||
|
return "invalidPackageName";
|
||||||
|
}
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String escapeReservedWord(String name) {
|
public String escapeReservedWord(String name) {
|
||||||
return name + "_";
|
return "_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -179,14 +179,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
// petId => pet_id
|
// petId => pet_id
|
||||||
name = underscore(dropDots(name));
|
name = underscore(dropDots(name));
|
||||||
|
|
||||||
|
// remove leading underscore
|
||||||
|
name = name.replaceAll("^_*", "");
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word or word starting with number, append _
|
||||||
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
|
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
|
||||||
name = escapeReservedWord(name);
|
name = escapeReservedWord(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove leading underscore
|
|
||||||
name = name.replaceAll("^_*", "");
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
|
|||||||
import {{invokerPackage}}.auth.ApiKeyAuth;
|
import {{invokerPackage}}.auth.ApiKeyAuth;
|
||||||
import {{invokerPackage}}.auth.OAuth;
|
import {{invokerPackage}}.auth.OAuth;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
private static ApiClient defaultApiClient = new ApiClient();
|
private static ApiClient defaultApiClient = new ApiClient();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class Pair {
|
public class Pair {
|
||||||
private String name = "";
|
private String name = "";
|
||||||
private String value = "";
|
private String value = "";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -3,6 +3,7 @@ package {{invokerPackage}};
|
|||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class TypeRef<T> {
|
public class TypeRef<T> {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}} {
|
public class {{classname}} {
|
||||||
private ApiClient {{localVariablePrefix}}apiClient;
|
private ApiClient {{localVariablePrefix}}apiClient;
|
||||||
|
@ -3,6 +3,7 @@ package {{invokerPackage}};
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception {
|
public class ApiException extends Exception {
|
||||||
private int code = 0;
|
private int code = 0;
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiKeyAuth implements Authentication {
|
public class ApiKeyAuth implements Authentication {
|
||||||
private final String location;
|
private final String location;
|
||||||
private final String paramName;
|
private final String paramName;
|
||||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public interface Authentication {
|
public interface Authentication {
|
||||||
/** Apply authentication settings to header and query params. */
|
/** Apply authentication settings to header and query params. */
|
||||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class HttpBasicAuth implements Authentication {
|
public class HttpBasicAuth implements Authentication {
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class OAuth implements Authentication {
|
public class OAuth implements Authentication {
|
||||||
@Override
|
@Override
|
||||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -43,6 +43,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
|
|||||||
import {{invokerPackage}}.auth.ApiKeyAuth;
|
import {{invokerPackage}}.auth.ApiKeyAuth;
|
||||||
import {{invokerPackage}}.auth.OAuth;
|
import {{invokerPackage}}.auth.OAuth;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
* {{description}}
|
* {{description}}
|
||||||
**/{{/description}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
@ApiModel(description = "{{{description}}}")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
{{#vars}}{{#isEnum}}
|
{{#vars}}{{#isEnum}}
|
||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
|
@ -13,6 +13,7 @@ import {{modelPackage}}.*;
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}} {
|
public class {{classname}} {
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
* {{description}}
|
* {{description}}
|
||||||
**/{{/description}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
@ApiModel(description = "{{{description}}}")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
{{#vars}}{{#isEnum}}
|
{{#vars}}{{#isEnum}}
|
||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception{
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
public ApiException (int code, String msg) {
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
|
@ -3,6 +3,7 @@ package {{apiPackage}};
|
|||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
@javax.xml.bind.annotation.XmlRootElement
|
@javax.xml.bind.annotation.XmlRootElement
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiResponseMessage {
|
public class ApiResponseMessage {
|
||||||
public static final int ERROR = 1;
|
public static final int ERROR = 1;
|
||||||
public static final int WARNING = 2;
|
public static final int WARNING = 2;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class NotFoundException extends ApiException {
|
public class NotFoundException extends ApiException {
|
||||||
private int code;
|
private int code;
|
||||||
public NotFoundException (int code, String msg) {
|
public NotFoundException (int code, String msg) {
|
||||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
|||||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||||
@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}} {
|
public class {{classname}} {
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
|||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public abstract class {{classname}}Service {
|
public abstract class {{classname}}Service {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
@ -3,6 +3,7 @@ package {{package}}.factories;
|
|||||||
import {{package}}.{{classname}}Service;
|
import {{package}}.{{classname}}Service;
|
||||||
import {{package}}.impl.{{classname}}ServiceImpl;
|
import {{package}}.impl.{{classname}}ServiceImpl;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}}ServiceFactory {
|
public class {{classname}}ServiceFactory {
|
||||||
|
|
||||||
private final static {{classname}}Service service = new {{classname}}ServiceImpl();
|
private final static {{classname}}Service service = new {{classname}}ServiceImpl();
|
||||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
|||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
* {{description}}
|
* {{description}}
|
||||||
**/{{/description}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
@ApiModel(description = "{{{description}}}")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
{{#vars}}{{#isEnum}}
|
{{#vars}}{{#isEnum}}
|
||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
|
@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*;
|
|||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE})
|
@RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE})
|
||||||
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}} {
|
public class {{classname}} {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception{
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
public ApiException (int code, String msg) {
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
|
@ -3,6 +3,7 @@ package {{apiPackage}};
|
|||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
@javax.xml.bind.annotation.XmlRootElement
|
@javax.xml.bind.annotation.XmlRootElement
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class ApiResponseMessage {
|
public class ApiResponseMessage {
|
||||||
public static final int ERROR = 1;
|
public static final int ERROR = 1;
|
||||||
public static final int WARNING = 2;
|
public static final int WARNING = 2;
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
* {{description}}
|
* {{description}}
|
||||||
**/{{/description}}
|
**/{{/description}}
|
||||||
@ApiModel(description = "{{{description}}}")
|
@ApiModel(description = "{{{description}}}")
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
{{#vars}}{{#isEnum}}
|
{{#vars}}{{#isEnum}}
|
||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class NotFoundException extends ApiException {
|
public class NotFoundException extends ApiException {
|
||||||
private int code;
|
private int code;
|
||||||
public NotFoundException (int code, String msg) {
|
public NotFoundException (int code, String msg) {
|
||||||
|
@ -18,6 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
@EnableSwagger2 //Loads the spring beans required by the framework
|
||||||
@PropertySource("classpath:swagger.properties")
|
@PropertySource("classpath:swagger.properties")
|
||||||
@Import(SwaggerUiConfiguration.class)
|
@Import(SwaggerUiConfiguration.class)
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@Bean
|
@Bean
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
|
@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package {{configPackage}};
|
|||||||
|
|
||||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package {{configPackage}};
|
|||||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
@Override
|
@Override
|
||||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||||
|
@ -1,52 +1,158 @@
|
|||||||
<html lang="en">
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<title>{{{appName}}}</title>
|
||||||
<title>API Reference</title>
|
<link rel="stylesheet" type="text/css" href="site.css" media="screen" />
|
||||||
|
<style type="text/css">
|
||||||
|
{{>style.css}}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>{{{appName}}}</h1>
|
<h1>{{{appName}}}</h1>
|
||||||
<div class="app-desc">{{{appDescription}}} for {{partner}}</div>
|
<div class="app-desc">{{{appDescription}}}</div>
|
||||||
{{#infoUrl}}<div class="app-desc">More information: <a href="{{{infoUrl}}}">{{{infoUrl}}}</a></div>{{/infoUrl}}
|
{{#infoUrl}}<div class="app-desc">More information: <a href="{{{infoUrl}}}">{{{infoUrl}}}</a></div>{{/infoUrl}}
|
||||||
{{#infoEmail}}<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>{{/infoEmail}}
|
{{#infoEmail}}<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>{{/infoEmail}}
|
||||||
{{#version}}<div class="app-desc">Version: {{{version}}}</div>{{/version}}
|
{{#version}}<div class="app-desc">Version: {{{version}}}</div>{{/version}}
|
||||||
<div class="license-info">{{{licenseInfo}}}</div>
|
<div class="license-info">{{{licenseInfo}}}</div>
|
||||||
<div class="license-url">{{{licenseUrl}}}</div>
|
<div class="license-url">{{{licenseUrl}}}</div>
|
||||||
<h2>Access</h2>
|
<h2>Access</h2>
|
||||||
<div class="method-summary">Customize this message as you see fit!</div>
|
{{access}}
|
||||||
<h2>Methods</h2>
|
|
||||||
|
<h2><a name="__Methods">Methods</a></h2>
|
||||||
|
[ Jump to <a href="#__Models">Models</a> ]
|
||||||
|
|
||||||
|
{{! for the tables of content, I cheat and don't use CSS styles.... }}
|
||||||
|
<h2>Table of Contents </h2>
|
||||||
|
<div class="method-summary">{{access}}</div>
|
||||||
|
{{#apiInfo}}
|
||||||
|
<ol>
|
||||||
|
{{#apis}}
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
<li><a href="#{{nickname}}"><code><span class="http-method">{{httpMethod}}</span> {{path}}</code></a></li>
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
</ol>
|
||||||
|
{{/apiInfo}}
|
||||||
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}
|
||||||
<div class="method">
|
{{#operation}}
|
||||||
<div class="method-path"><pre class="{{httpMethod}}"><code class="huge"><span>{{httpMethod}}</span>: {{path}}</code></pre></div>
|
<div class="method"><a name="{{nickname}}"/>
|
||||||
<div class="method-tags"> {{#tags}}<span class="method-tag">{{this}}</span>{{/tags}}</div>
|
<div class="method-path">
|
||||||
<div class="method-summary"><span class="nickname">{{nickname}}</span> {{summary}}</div>
|
<a class="up" href="#__Methods">Up</a>
|
||||||
|
<pre class="{{httpMethod}}"><code class="huge"><span class="http-method">{{httpMethod}}</span> {{path}}</code></pre></div>
|
||||||
|
<div class="method-summary">{{summary}} (<span class="nickname">{{nickname}}</span>)</div>
|
||||||
|
{{! notes is operation.description. So why rename it and make it super confusing???? }}
|
||||||
<div class="method-notes">{{notes}}</div>
|
<div class="method-notes">{{notes}}</div>
|
||||||
|
|
||||||
<h3 class="field-label">Parameters</h3>
|
{{#hasPathParams}}
|
||||||
|
<h3 class="field-label">Path parameters</h3>
|
||||||
<div class="field-items">
|
<div class="field-items">
|
||||||
{{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>headerParam}}{{>formParam}}
|
{{#pathParams}}{{>pathParam}}{{/pathParams}}
|
||||||
{{/allParams}}
|
|
||||||
</div> <!-- field-items -->
|
</div> <!-- field-items -->
|
||||||
|
{{/hasPathParams}}
|
||||||
|
|
||||||
|
{{#hasConsumes}}
|
||||||
|
<h3 class="field-label">Consumes</h3>
|
||||||
|
This API call consumes the following media types via the <span class="heaader">Content-Type</span> request header:
|
||||||
|
<ul>
|
||||||
|
{{#consumes}}
|
||||||
|
<li><code>{{mediaType}}</code></li>
|
||||||
|
{{/consumes}}
|
||||||
|
</ul>
|
||||||
|
{{/hasConsumes}}
|
||||||
|
|
||||||
|
{{#hasBodyParam}}
|
||||||
|
<h3 class="field-label">Request body</h3>
|
||||||
|
<div class="field-items">
|
||||||
|
{{#bodyParams}}{{>bodyParam}}{{/bodyParams}}
|
||||||
|
</div> <!-- field-items -->
|
||||||
|
{{/hasBodyParam}}
|
||||||
|
|
||||||
|
{{#hasHeaderParam}}
|
||||||
|
<h3 class="field-label">Request headers</h3>
|
||||||
|
<div class="field-items">
|
||||||
|
{{#headerParam}}{{>headerParam}}{{/headerParam}}
|
||||||
|
</div> <!-- field-items -->
|
||||||
|
{{/hasHeaderParam}}
|
||||||
|
|
||||||
|
{{#hasQueryParams}}
|
||||||
|
<h3 class="field-label">Query parameters</h3>
|
||||||
|
<div class="field-items">
|
||||||
|
{{#queryParams}}{{>queryParam}}{{/queryParams}}
|
||||||
|
</div> <!-- field-items -->
|
||||||
|
{{/hasQueryParams}}
|
||||||
|
|
||||||
|
<!-- Remove Return type... unclear where this comes from;
|
||||||
|
for our swagger.json files, it is always empty and there is no boolean guard or hasReturnType
|
||||||
|
do we end up with a heading but not content
|
||||||
|
|
||||||
|
{{#returnType}}
|
||||||
<h3 class="field-label">Return type</h3>
|
<h3 class="field-label">Return type</h3>
|
||||||
|
|
||||||
<div class="return-type"><a href="#{{returnContainer}}">{{{returnType}}}</a></div>
|
<div class="return-type"><a href="#{{returnContainer}}">{{{returnType}}}</a></div>
|
||||||
|
{{/returnType}}
|
||||||
|
|
||||||
|
Todo: process Response Object and its headers, schema, examples
|
||||||
|
-->
|
||||||
|
|
||||||
|
{{#hasExamples}}
|
||||||
|
{{#examples}}
|
||||||
|
<h3 class="field-label">Example data</h3>
|
||||||
|
<div class="example-data-content-type">Content-Type: {{{contentType}}}</div>
|
||||||
|
<pre class="example"><code>{{{example}}}</code></pre>
|
||||||
|
{{/examples}}
|
||||||
|
{{/hasExamples}}
|
||||||
|
|
||||||
|
{{#hasProduces}}
|
||||||
|
<h3 class="field-label">Produces</h3>
|
||||||
|
This API call produces the following media types according to the <span class="header">Accept</span> request header;
|
||||||
|
the media type will be conveyed by the <span class="heaader">Content-Type</span> response header.
|
||||||
|
<ul>
|
||||||
|
{{#produces}}
|
||||||
|
<li><code>{{mediaType}}</code></li>
|
||||||
|
{{/produces}}
|
||||||
|
</ul>
|
||||||
|
{{/hasProduces}}
|
||||||
|
|
||||||
|
<h3 class="field-label">Responses</h3>
|
||||||
|
{{#responses}}
|
||||||
|
<h4 class="field-label">{{code}}</h4>
|
||||||
|
{{message}}
|
||||||
{{#examples}}
|
{{#examples}}
|
||||||
<h3 class="field-label">Example data</h3>
|
<h3 class="field-label">Example data</h3>
|
||||||
<div class="example-data-content-type">Content-Type: {{{contentType}}}</div>
|
<div class="example-data-content-type">Content-Type: {{{contentType}}}</div>
|
||||||
<pre class="example"><code>{{example}}</code></pre>
|
<pre class="example"><code>{{example}}</code></pre>
|
||||||
{{/examples}}
|
{{/examples}}
|
||||||
|
{{/responses}}
|
||||||
</div> <!-- method -->
|
</div> <!-- method -->
|
||||||
<hr>
|
<hr/>
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}
|
||||||
{{/apis}}{{/apiInfo}}
|
{{/operations}}
|
||||||
|
{{/apis}}
|
||||||
|
{{/apiInfo}}
|
||||||
|
|
||||||
|
<div class="up"><a href="#__Models">Up</a></div>
|
||||||
|
<h2><a name="__Models">Models</a></h2>
|
||||||
|
[ Jump to <a href="#__Methods">Methods</a> ]
|
||||||
|
|
||||||
|
<h2>Table of Contents</h2>
|
||||||
|
<ol>
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
<li><a href="#{{classname}}"><code>{{classname}}</code></a></li>
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
||||||
|
</ol>
|
||||||
|
|
||||||
<h2>Models</h2>
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
<div class="model">
|
<div class="model">
|
||||||
<h3 class="field-label"><a name="{{classname}}">{{classname}}</a></h3>
|
<h3 class="field-label"><a name="{{classname}}">{{classname}}</a> <a class="up" href="#__Models">Up</a></h3>
|
||||||
<div class="field-items">
|
<div class="field-items">
|
||||||
{{#vars}}<div class="param">{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}</div><div class="param-desc"><span class="param-type">{{datatype}}</span> {{description}}</div>
|
{{#vars}}<div class="param">{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}</div><div class="param-desc"><span class="param-type">{{datatype}}</span> {{description}}</div>
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
@ -54,8 +160,5 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
<style>
|
|
||||||
{{>style.css}}
|
|
||||||
</style>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -57,6 +57,10 @@ pre {
|
|||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.http-method {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
pre.get {
|
pre.get {
|
||||||
background-color: #0f6ab4;
|
background-color: #0f6ab4;
|
||||||
}
|
}
|
||||||
@ -96,6 +100,10 @@ code {
|
|||||||
background-color: #0f6ab4;
|
background-color: #0f6ab4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.up {
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
|
||||||
.parameter {
|
.parameter {
|
||||||
width: 500px;
|
width: 500px;
|
||||||
}
|
}
|
||||||
|
@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
|
|
||||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||||
method: (NSString*) method
|
method: (NSString*) method
|
||||||
|
pathParams: (NSDictionary *) pathParams
|
||||||
queryParams: (NSDictionary*) queryParams
|
queryParams: (NSDictionary*) queryParams
|
||||||
formParams: (NSDictionary *) formParams
|
formParams: (NSDictionary *) formParams
|
||||||
files: (NSDictionary *) files
|
files: (NSDictionary *) files
|
||||||
@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sanitize parameters
|
||||||
|
pathParams = [self sanitizeForSerialization:pathParams];
|
||||||
|
queryParams = [self sanitizeForSerialization:queryParams];
|
||||||
|
headerParams = [self sanitizeForSerialization:headerParams];
|
||||||
|
formParams = [self sanitizeForSerialization:formParams];
|
||||||
|
body = [self sanitizeForSerialization:body];
|
||||||
|
|
||||||
// auth setting
|
// auth setting
|
||||||
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
||||||
|
|
||||||
|
NSMutableString *resourcePath = [NSMutableString stringWithString:path];
|
||||||
|
[pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
[resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]]
|
||||||
|
withString:[SWGApiClient escape:obj]];
|
||||||
|
}];
|
||||||
|
|
||||||
NSMutableURLRequest * request = nil;
|
NSMutableURLRequest * request = nil;
|
||||||
|
|
||||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
|
||||||
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
||||||
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
||||||
}
|
}
|
||||||
@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// request cache
|
||||||
BOOL hasHeaderParams = false;
|
BOOL hasHeaderParams = false;
|
||||||
if(headerParams != nil && [headerParams count] > 0) {
|
if(headerParams != nil && [headerParams count] > 0) {
|
||||||
hasHeaderParams = true;
|
hasHeaderParams = true;
|
||||||
}
|
}
|
||||||
if(offlineState) {
|
if(offlineState) {
|
||||||
NSLog(@"%@ cache forced", path);
|
NSLog(@"%@ cache forced", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||||
}
|
}
|
||||||
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
||||||
NSLog(@"%@ cache enabled", path);
|
NSLog(@"%@ cache enabled", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSLog(@"%@ cache disabled", path);
|
NSLog(@"%@ cache disabled", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) sanitizeForSerialization:(id) object {
|
||||||
|
if (object == nil) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDate class]]) {
|
||||||
|
return [object ISO8601String];
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]];
|
||||||
|
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
if (obj) {
|
||||||
|
[sanitizedObjs addObject:[self sanitizeForSerialization:obj]];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]];
|
||||||
|
[object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
if (obj) {
|
||||||
|
[sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[SWGObject class]]) {
|
||||||
|
return [object toDictionary];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -168,6 +168,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
|||||||
*
|
*
|
||||||
* @param path Request url.
|
* @param path Request url.
|
||||||
* @param method Request method.
|
* @param method Request method.
|
||||||
|
* @param pathParams Request path parameters.
|
||||||
* @param queryParams Request query parameters.
|
* @param queryParams Request query parameters.
|
||||||
* @param body Request body.
|
* @param body Request body.
|
||||||
* @param headerParams Request header parameters.
|
* @param headerParams Request header parameters.
|
||||||
@ -180,6 +181,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
|||||||
*/
|
*/
|
||||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
|
pathParams:(NSDictionary *) pathParams
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
formParams:(NSDictionary *) formParams
|
formParams:(NSDictionary *) formParams
|
||||||
files:(NSDictionary *) files
|
files:(NSDictionary *) files
|
||||||
@ -191,4 +193,11 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
|||||||
responseType:(NSString *) responseType
|
responseType:(NSString *) responseType
|
||||||
completionBlock:(void (^)(id, NSError *))completionBlock;
|
completionBlock:(void (^)(id, NSError *))completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize object for request
|
||||||
|
*
|
||||||
|
* @param object The query/path/header/form/body param to be sanitized.
|
||||||
|
*/
|
||||||
|
- (id) sanitizeForSerialization:(id) object;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -88,8 +88,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#pathParams}}[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"{{baseName}}", @"}"]] withString: [{{classPrefix}}ApiClient escape:{{paramName}}]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
{{#pathParams}}if ({{paramName}} != nil) {
|
||||||
|
pathParams[@"{{baseName}}"] = {{paramName}};
|
||||||
|
}
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -132,26 +135,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
{{#bodyParam}}
|
{{#bodyParam}}
|
||||||
bodyParam = {{paramName}};
|
bodyParam = {{paramName}};
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[({{classPrefix}}Object*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
{{/bodyParam}}{{^bodyParam}}
|
{{/bodyParam}}{{^bodyParam}}
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#notFile}}
|
{{#notFile}}
|
||||||
formParams[@"{{paramName}}"] = {{paramName}};
|
if ({{paramName}}) {
|
||||||
|
formParams[@"{{baseName}}"] = {{paramName}};
|
||||||
|
}
|
||||||
{{/notFile}}{{#isFile}}
|
{{/notFile}}{{#isFile}}
|
||||||
files[@"{{paramName}}"] = {{paramName}};
|
files[@"{{paramName}}"] = {{paramName}};
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
@ -167,6 +156,7 @@
|
|||||||
{{/requiredParamCount}}
|
{{/requiredParamCount}}
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"{{httpMethod}}"
|
method: @"{{httpMethod}}"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
|
@ -202,11 +202,9 @@ class ApiClient(object):
|
|||||||
# and attributes which value is not None.
|
# and attributes which value is not None.
|
||||||
# Convert attribute name to json key in
|
# Convert attribute name to json key in
|
||||||
# model definition for request.
|
# model definition for request.
|
||||||
obj_dict = {obj.attribute_map[key[1:]]: val
|
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
|
||||||
for key, val in iteritems(obj.__dict__)
|
for attr, _ in iteritems(obj.swagger_types)
|
||||||
if key != 'swagger_types'
|
if getattr(obj, attr) is not None}
|
||||||
and key != 'attribute_map'
|
|
||||||
and val is not None}
|
|
||||||
|
|
||||||
return {key: self.sanitize_for_serialization(val)
|
return {key: self.sanitize_for_serialization(val)
|
||||||
for key, val in iteritems(obj_dict)}
|
for key, val in iteritems(obj_dict)}
|
||||||
|
@ -23,9 +23,9 @@ import urllib3
|
|||||||
try:
|
try:
|
||||||
import httplib
|
import httplib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# python3
|
# for python3
|
||||||
import http.client as httplib
|
import http.client as httplib
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -86,18 +86,17 @@ class {{classname}}(object):
|
|||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for name, prop in iteritems(self.__dict__):
|
for attr, _ in iteritems(self.swagger_types):
|
||||||
if name == "attribute_map" or name == "swagger_types":
|
value = getattr(self, attr)
|
||||||
continue
|
if isinstance(value, list):
|
||||||
if isinstance(prop, list):
|
result[attr] = list(map(
|
||||||
result[name[1:]] = list(map(
|
|
||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
prop
|
value
|
||||||
))
|
))
|
||||||
elif hasattr(prop, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[name[1:]] = prop.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
result[name[1:]] = prop
|
result[attr] = value
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package Java
|
|||||||
|
|
||||||
import io.swagger.codegen.languages.JavaClientCodegen
|
import io.swagger.codegen.languages.JavaClientCodegen
|
||||||
import io.swagger.models._
|
import io.swagger.models._
|
||||||
|
import io.swagger.models.parameters._
|
||||||
import io.swagger.models.properties._
|
import io.swagger.models.properties._
|
||||||
import io.swagger.util.Json
|
import io.swagger.util.Json
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@ -382,7 +383,6 @@ class JavaModelTest2 extends FlatSpec with Matchers {
|
|||||||
cm.vars.size should be(1)
|
cm.vars.size should be(1)
|
||||||
|
|
||||||
val vars = cm.vars
|
val vars = cm.vars
|
||||||
Json.prettyPrint(vars.get(0))
|
|
||||||
vars.get(0).baseName should be("_")
|
vars.get(0).baseName should be("_")
|
||||||
vars.get(0).getter should be("getU")
|
vars.get(0).getter should be("getU")
|
||||||
vars.get(0).setter should be("setU")
|
vars.get(0).setter should be("setU")
|
||||||
@ -393,4 +393,17 @@ class JavaModelTest2 extends FlatSpec with Matchers {
|
|||||||
vars.get(0).hasMore should equal(null)
|
vars.get(0).hasMore should equal(null)
|
||||||
vars.get(0).isNotContainer should equal(true)
|
vars.get(0).isNotContainer should equal(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it should "convert a parameter" in {
|
||||||
|
val parameter = new QueryParameter()
|
||||||
|
.property(
|
||||||
|
new IntegerProperty())
|
||||||
|
.name("limit")
|
||||||
|
.required(true)
|
||||||
|
|
||||||
|
val codegen = new JavaClientCodegen()
|
||||||
|
val cp = codegen.fromParameter(parameter, null)
|
||||||
|
|
||||||
|
cp.allowableValues should be (null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
|||||||
import io.swagger.client.auth.ApiKeyAuth;
|
import io.swagger.client.auth.ApiKeyAuth;
|
||||||
import io.swagger.client.auth.OAuth;
|
import io.swagger.client.auth.OAuth;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class ApiException extends Exception {
|
public class ApiException extends Exception {
|
||||||
private int code = 0;
|
private int code = 0;
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
private static ApiClient defaultApiClient = new ApiClient();
|
private static ApiClient defaultApiClient = new ApiClient();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Pair {
|
public class Pair {
|
||||||
private String name = "";
|
private String name = "";
|
||||||
private String value = "";
|
private String value = "";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
|||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class TypeRef<T> {
|
public class TypeRef<T> {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class ApiKeyAuth implements Authentication {
|
public class ApiKeyAuth implements Authentication {
|
||||||
private final String location;
|
private final String location;
|
||||||
private final String paramName;
|
private final String paramName;
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public interface Authentication {
|
public interface Authentication {
|
||||||
/** Apply authentication settings to header and query params. */
|
/** Apply authentication settings to header and query params. */
|
||||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class HttpBasicAuth implements Authentication {
|
public class HttpBasicAuth implements Authentication {
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class OAuth implements Authentication {
|
public class OAuth implements Authentication {
|
||||||
@Override
|
@Override
|
||||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class Tag {
|
public class Tag {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -43,6 +43,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
|||||||
import io.swagger.client.auth.ApiKeyAuth;
|
import io.swagger.client.auth.ApiKeyAuth;
|
||||||
import io.swagger.client.auth.OAuth;
|
import io.swagger.client.auth.OAuth;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class ApiException extends Exception {
|
public class ApiException extends Exception {
|
||||||
private int code = 0;
|
private int code = 0;
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
private static ApiClient defaultApiClient = new ApiClient();
|
private static ApiClient defaultApiClient = new ApiClient();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Pair {
|
public class Pair {
|
||||||
private String name = "";
|
private String name = "";
|
||||||
private String value = "";
|
private String value = "";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
|||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class TypeRef<T> {
|
public class TypeRef<T> {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class ApiKeyAuth implements Authentication {
|
public class ApiKeyAuth implements Authentication {
|
||||||
private final String location;
|
private final String location;
|
||||||
private final String paramName;
|
private final String paramName;
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public interface Authentication {
|
public interface Authentication {
|
||||||
/** Apply authentication settings to header and query params. */
|
/** Apply authentication settings to header and query params. */
|
||||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class HttpBasicAuth implements Authentication {
|
public class HttpBasicAuth implements Authentication {
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class OAuth implements Authentication {
|
public class OAuth implements Authentication {
|
||||||
@Override
|
@Override
|
||||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class Tag {
|
public class Tag {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -172,6 +172,7 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
*
|
*
|
||||||
* @param path Request url.
|
* @param path Request url.
|
||||||
* @param method Request method.
|
* @param method Request method.
|
||||||
|
* @param pathParams Request path parameters.
|
||||||
* @param queryParams Request query parameters.
|
* @param queryParams Request query parameters.
|
||||||
* @param body Request body.
|
* @param body Request body.
|
||||||
* @param headerParams Request header parameters.
|
* @param headerParams Request header parameters.
|
||||||
@ -184,6 +185,7 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
*/
|
*/
|
||||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||||
method:(NSString*) method
|
method:(NSString*) method
|
||||||
|
pathParams:(NSDictionary *) pathParams
|
||||||
queryParams:(NSDictionary*) queryParams
|
queryParams:(NSDictionary*) queryParams
|
||||||
formParams:(NSDictionary *) formParams
|
formParams:(NSDictionary *) formParams
|
||||||
files:(NSDictionary *) files
|
files:(NSDictionary *) files
|
||||||
@ -195,4 +197,11 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
responseType:(NSString *) responseType
|
responseType:(NSString *) responseType
|
||||||
completionBlock:(void (^)(id, NSError *))completionBlock;
|
completionBlock:(void (^)(id, NSError *))completionBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize object for request
|
||||||
|
*
|
||||||
|
* @param object The query/path/header/form/body param to be sanitized.
|
||||||
|
*/
|
||||||
|
- (id) sanitizeForSerialization:(id) object;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
|
|
||||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||||
method: (NSString*) method
|
method: (NSString*) method
|
||||||
|
pathParams: (NSDictionary *) pathParams
|
||||||
queryParams: (NSDictionary*) queryParams
|
queryParams: (NSDictionary*) queryParams
|
||||||
formParams: (NSDictionary *) formParams
|
formParams: (NSDictionary *) formParams
|
||||||
files: (NSDictionary *) files
|
files: (NSDictionary *) files
|
||||||
@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sanitize parameters
|
||||||
|
pathParams = [self sanitizeForSerialization:pathParams];
|
||||||
|
queryParams = [self sanitizeForSerialization:queryParams];
|
||||||
|
headerParams = [self sanitizeForSerialization:headerParams];
|
||||||
|
formParams = [self sanitizeForSerialization:formParams];
|
||||||
|
body = [self sanitizeForSerialization:body];
|
||||||
|
|
||||||
// auth setting
|
// auth setting
|
||||||
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
||||||
|
|
||||||
|
NSMutableString *resourcePath = [NSMutableString stringWithString:path];
|
||||||
|
[pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
[resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]]
|
||||||
|
withString:[SWGApiClient escape:obj]];
|
||||||
|
}];
|
||||||
|
|
||||||
NSMutableURLRequest * request = nil;
|
NSMutableURLRequest * request = nil;
|
||||||
|
|
||||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
|
||||||
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
||||||
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
||||||
}
|
}
|
||||||
@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// request cache
|
||||||
BOOL hasHeaderParams = false;
|
BOOL hasHeaderParams = false;
|
||||||
if(headerParams != nil && [headerParams count] > 0) {
|
if(headerParams != nil && [headerParams count] > 0) {
|
||||||
hasHeaderParams = true;
|
hasHeaderParams = true;
|
||||||
}
|
}
|
||||||
if(offlineState) {
|
if(offlineState) {
|
||||||
NSLog(@"%@ cache forced", path);
|
NSLog(@"%@ cache forced", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||||
}
|
}
|
||||||
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
||||||
NSLog(@"%@ cache enabled", path);
|
NSLog(@"%@ cache enabled", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSLog(@"%@ cache disabled", path);
|
NSLog(@"%@ cache disabled", resourcePath);
|
||||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) sanitizeForSerialization:(id) object {
|
||||||
|
if (object == nil) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDate class]]) {
|
||||||
|
return [object ISO8601String];
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]];
|
||||||
|
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
if (obj) {
|
||||||
|
[sanitizedObjs addObject:[self sanitizeForSerialization:obj]];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]];
|
||||||
|
[object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
|
if (obj) {
|
||||||
|
[sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return sanitizedObjs;
|
||||||
|
}
|
||||||
|
else if ([object isKindOfClass:[SWGObject class]]) {
|
||||||
|
return [object toDictionary];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SWGTag.h"
|
|
||||||
#import "SWGCategory.h"
|
#import "SWGCategory.h"
|
||||||
|
#import "SWGTag.h"
|
||||||
|
|
||||||
|
|
||||||
@protocol SWGPet
|
@protocol SWGPet
|
||||||
|
@ -80,7 +80,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -115,27 +116,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"PUT"
|
method: @"PUT"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -172,7 +158,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -207,27 +194,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -264,7 +236,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -310,6 +283,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -346,7 +320,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -392,6 +367,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -433,8 +409,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (petId != nil) {
|
||||||
|
pathParams[@"petId"] = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -462,7 +441,7 @@
|
|||||||
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
// Authentication setting
|
// Authentication setting
|
||||||
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
|
NSArray *authSettings = @[@"petstore_auth", @"api_key"];
|
||||||
|
|
||||||
id bodyParam = nil;
|
id bodyParam = nil;
|
||||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -474,6 +453,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -521,8 +501,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (petId != nil) {
|
||||||
|
pathParams[@"petId"] = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -558,11 +541,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
formParams[@"name"] = name;
|
if (name) {
|
||||||
|
formParams[@"name"] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
formParams[@"status"] = status;
|
if (status) {
|
||||||
|
formParams[@"status"] = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -570,6 +557,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -614,8 +602,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (petId != nil) {
|
||||||
|
pathParams[@"petId"] = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -657,6 +648,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"DELETE"
|
method: @"DELETE"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -704,8 +696,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (petId != nil) {
|
||||||
|
pathParams[@"petId"] = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -741,7 +736,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
if (additionalMetadata) {
|
||||||
|
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -753,6 +750,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
|
@ -77,7 +77,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -117,6 +118,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -153,7 +155,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -188,27 +191,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -250,8 +238,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (orderId != nil) {
|
||||||
|
pathParams[@"orderId"] = orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -291,6 +282,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -332,8 +324,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (orderId != nil) {
|
||||||
|
pathParams[@"orderId"] = orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -373,6 +368,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"DELETE"
|
method: @"DELETE"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
|
@ -80,7 +80,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -115,27 +116,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -172,7 +158,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -207,27 +194,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -264,7 +236,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -299,27 +272,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"POST"
|
method: @"POST"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -359,7 +317,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -407,6 +366,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -440,7 +400,8 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -480,6 +441,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -521,8 +483,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (username != nil) {
|
||||||
|
pathParams[@"username"] = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -562,6 +527,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -606,8 +572,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (username != nil) {
|
||||||
|
pathParams[@"username"] = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -642,27 +611,12 @@
|
|||||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
bodyParam = body;
|
bodyParam = body;
|
||||||
|
|
||||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
|
||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
[objs addObject:dict];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bodyParam = objs;
|
|
||||||
}
|
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"PUT"
|
method: @"PUT"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
@ -704,8 +658,11 @@
|
|||||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
|
if (username != nil) {
|
||||||
|
pathParams[@"username"] = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
@ -745,6 +702,7 @@
|
|||||||
|
|
||||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||||
method: @"DELETE"
|
method: @"DELETE"
|
||||||
|
pathParams: pathParams
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
formParams: formParams
|
formParams: formParams
|
||||||
files: files
|
files: files
|
||||||
|
@ -202,11 +202,9 @@ class ApiClient(object):
|
|||||||
# and attributes which value is not None.
|
# and attributes which value is not None.
|
||||||
# Convert attribute name to json key in
|
# Convert attribute name to json key in
|
||||||
# model definition for request.
|
# model definition for request.
|
||||||
obj_dict = {obj.attribute_map[key[1:]]: val
|
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
|
||||||
for key, val in iteritems(obj.__dict__)
|
for attr, _ in iteritems(obj.swagger_types)
|
||||||
if key != 'swagger_types'
|
if getattr(obj, attr) is not None}
|
||||||
and key != 'attribute_map'
|
|
||||||
and val is not None}
|
|
||||||
|
|
||||||
return {key: self.sanitize_for_serialization(val)
|
return {key: self.sanitize_for_serialization(val)
|
||||||
for key, val in iteritems(obj_dict)}
|
for key, val in iteritems(obj_dict)}
|
||||||
|
@ -23,9 +23,9 @@ import urllib3
|
|||||||
try:
|
try:
|
||||||
import httplib
|
import httplib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# python3
|
# for python3
|
||||||
import http.client as httplib
|
import http.client as httplib
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -97,18 +97,17 @@ class Category(object):
|
|||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for name, prop in iteritems(self.__dict__):
|
for attr, _ in iteritems(self.swagger_types):
|
||||||
if name == "attribute_map" or name == "swagger_types":
|
value = getattr(self, attr)
|
||||||
continue
|
if isinstance(value, list):
|
||||||
if isinstance(prop, list):
|
result[attr] = list(map(
|
||||||
result[name[1:]] = list(map(
|
|
||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
prop
|
value
|
||||||
))
|
))
|
||||||
elif hasattr(prop, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[name[1:]] = prop.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
result[name[1:]] = prop
|
result[attr] = value
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user