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 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
|
||||
public String nickname;
|
||||
}
|
||||
|
@ -639,7 +639,9 @@ public class DefaultCodegen {
|
||||
if (np.getMaximum() != null) {
|
||||
allowableValues.put("max", np.getMaximum());
|
||||
}
|
||||
property.allowableValues = allowableValues;
|
||||
if(allowableValues.size() > 0) {
|
||||
property.allowableValues = allowableValues;
|
||||
}
|
||||
}
|
||||
|
||||
if (p instanceof StringProperty) {
|
||||
|
@ -17,6 +17,7 @@ import io.swagger.models.parameters.Parameter;
|
||||
import io.swagger.util.Json;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -63,6 +64,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
List<File> files = new ArrayList<File>();
|
||||
try {
|
||||
config.processOpts();
|
||||
|
||||
config.additionalProperties().put("generatedDate", DateTime.now().toString());
|
||||
config.additionalProperties().put("generatorClass", config.getClass().toString());
|
||||
|
||||
if (swagger.getInfo() != null) {
|
||||
Info info = swagger.getInfo();
|
||||
if (info.getTitle() != null) {
|
||||
@ -189,7 +194,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
for (String templateName : config.apiTemplateFiles().keySet()) {
|
||||
|
||||
String filename = config.apiFilename(templateName, tag);
|
||||
if (!config.shouldOverwrite(filename)) {
|
||||
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
|
||||
if (additionalProperties.containsKey("invokerPackage")) {
|
||||
this.setInvokerPackage((String) additionalProperties.get("invokerPackage"));
|
||||
} else {
|
||||
@ -134,6 +134,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix"));
|
||||
}
|
||||
|
||||
this.sanitizeConfig();
|
||||
|
||||
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
@ -347,4 +368,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public void setLocalVariablePrefix(String 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
|
||||
public String escapeReservedWord(String name) {
|
||||
return name + "_";
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,14 +179,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
// petId => pet_id
|
||||
name = underscore(dropDots(name));
|
||||
|
||||
// remove leading underscore
|
||||
name = name.replaceAll("^_*", "");
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
// remove leading underscore
|
||||
name = name.replaceAll("^_*", "");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
|
||||
import {{invokerPackage}}.auth.ApiKeyAuth;
|
||||
import {{invokerPackage}}.auth.OAuth;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class JSON {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class StringUtil {
|
||||
/**
|
||||
* 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.Type;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient {{localVariablePrefix}}apiClient;
|
||||
|
@ -3,6 +3,7 @@ package {{invokerPackage}};
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
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.OAuth;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -13,6 +13,7 @@ import {{modelPackage}}.*;
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
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}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
private int code;
|
||||
public ApiException (int code, String msg) {
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
|
@ -3,6 +3,7 @@ package {{apiPackage}};
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@javax.xml.bind.annotation.XmlRootElement
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiResponseMessage {
|
||||
public static final int ERROR = 1;
|
||||
public static final int WARNING = 2;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class NotFoundException extends ApiException {
|
||||
private int code;
|
||||
public NotFoundException (int code, String msg) {
|
||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||
@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
|
||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public abstract class {{classname}}Service {
|
||||
{{#operation}}
|
||||
|
@ -3,6 +3,7 @@ package {{package}}.factories;
|
||||
import {{package}}.{{classname}}Service;
|
||||
import {{package}}.impl.{{classname}}ServiceImpl;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}}ServiceFactory {
|
||||
|
||||
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;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
||||
{{#operation}}
|
||||
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*;
|
||||
@Controller
|
||||
@RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE})
|
||||
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
{{#operation}}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
private int code;
|
||||
public ApiException (int code, String msg) {
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
|
@ -3,6 +3,7 @@ package {{apiPackage}};
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@javax.xml.bind.annotation.XmlRootElement
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiResponseMessage {
|
||||
public static final int ERROR = 1;
|
||||
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}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class NotFoundException extends ApiException {
|
||||
private int code;
|
||||
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
|
||||
@PropertySource("classpath:swagger.properties")
|
||||
@Import(SwaggerUiConfiguration.class)
|
||||
{{>generatedAnnotation}}
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
ApiInfo apiInfo() {
|
||||
|
@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
{{>generatedAnnotation}}
|
||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||
|
||||
|
@ -2,6 +2,7 @@ package {{configPackage}};
|
||||
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package {{configPackage}};
|
||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
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>
|
||||
<meta charset="utf-8" />
|
||||
<title>API Reference</title>
|
||||
<title>{{{appName}}}</title>
|
||||
<link rel="stylesheet" type="text/css" href="site.css" media="screen" />
|
||||
<style type="text/css">
|
||||
{{>style.css}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<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}}
|
||||
{{#infoEmail}}<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>{{/infoEmail}}
|
||||
{{#version}}<div class="app-desc">Version: {{{version}}}</div>{{/version}}
|
||||
<div class="license-info">{{{licenseInfo}}}</div>
|
||||
<div class="license-url">{{{licenseUrl}}}</div>
|
||||
<h2>Access</h2>
|
||||
<div class="method-summary">Customize this message as you see fit!</div>
|
||||
<h2>Methods</h2>
|
||||
{{access}}
|
||||
|
||||
<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}}
|
||||
{{#apis}}
|
||||
{{#operations}}{{#operation}}
|
||||
<div class="method">
|
||||
<div class="method-path"><pre class="{{httpMethod}}"><code class="huge"><span>{{httpMethod}}</span>: {{path}}</code></pre></div>
|
||||
<div class="method-tags"> {{#tags}}<span class="method-tag">{{this}}</span>{{/tags}}</div>
|
||||
<div class="method-summary"><span class="nickname">{{nickname}}</span> {{summary}}</div>
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
<div class="method"><a name="{{nickname}}"/>
|
||||
<div class="method-path">
|
||||
<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>
|
||||
|
||||
<h3 class="field-label">Parameters</h3>
|
||||
{{#hasPathParams}}
|
||||
<h3 class="field-label">Path parameters</h3>
|
||||
<div class="field-items">
|
||||
{{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>headerParam}}{{>formParam}}
|
||||
{{/allParams}}
|
||||
{{#pathParams}}{{>pathParam}}{{/pathParams}}
|
||||
</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>
|
||||
|
||||
<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}}
|
||||
<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}}
|
||||
{{/responses}}
|
||||
</div> <!-- method -->
|
||||
<hr>
|
||||
{{/operation}}{{/operations}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
<hr/>
|
||||
{{/operation}}
|
||||
{{/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}}
|
||||
{{#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">
|
||||
{{#vars}}<div class="param">{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}</div><div class="param-desc"><span class="param-type">{{datatype}}</span> {{description}}</div>
|
||||
{{/vars}}
|
||||
@ -54,8 +160,5 @@
|
||||
</div>
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
<style>
|
||||
{{>style.css}}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
@ -57,6 +57,10 @@ pre {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.http-method {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
pre.get {
|
||||
background-color: #0f6ab4;
|
||||
}
|
||||
@ -96,6 +100,10 @@ code {
|
||||
background-color: #0f6ab4;
|
||||
}
|
||||
|
||||
.up {
|
||||
float:right;
|
||||
}
|
||||
|
||||
.parameter {
|
||||
width: 500px;
|
||||
}
|
||||
|
@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int);
|
||||
|
||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||
method: (NSString*) method
|
||||
pathParams: (NSDictionary *) pathParams
|
||||
queryParams: (NSDictionary*) queryParams
|
||||
formParams: (NSDictionary *) formParams
|
||||
files: (NSDictionary *) files
|
||||
@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int);
|
||||
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
|
||||
[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;
|
||||
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
|
||||
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
||||
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
||||
}
|
||||
@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int);
|
||||
}
|
||||
}
|
||||
|
||||
// request cache
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
}
|
||||
if(offlineState) {
|
||||
NSLog(@"%@ cache forced", path);
|
||||
NSLog(@"%@ cache forced", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||
}
|
||||
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
||||
NSLog(@"%@ cache enabled", path);
|
||||
NSLog(@"%@ cache enabled", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
||||
}
|
||||
else {
|
||||
NSLog(@"%@ cache disabled", path);
|
||||
NSLog(@"%@ cache disabled", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||
}
|
||||
|
||||
@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int);
|
||||
*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
|
||||
|
@ -168,6 +168,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
||||
*
|
||||
* @param path Request url.
|
||||
* @param method Request method.
|
||||
* @param pathParams Request path parameters.
|
||||
* @param queryParams Request query parameters.
|
||||
* @param body Request body.
|
||||
* @param headerParams Request header parameters.
|
||||
@ -180,6 +181,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
||||
*/
|
||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
pathParams:(NSDictionary *) pathParams
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
formParams:(NSDictionary *) formParams
|
||||
files:(NSDictionary *) files
|
||||
@ -191,4 +193,11 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
||||
responseType:(NSString *) responseType
|
||||
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
|
||||
|
@ -88,8 +88,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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}}
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -132,26 +135,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
{{#bodyParam}}
|
||||
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}}
|
||||
{{#formParams}}
|
||||
{{#notFile}}
|
||||
formParams[@"{{paramName}}"] = {{paramName}};
|
||||
if ({{paramName}}) {
|
||||
formParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
{{/notFile}}{{#isFile}}
|
||||
files[@"{{paramName}}"] = {{paramName}};
|
||||
{{/isFile}}
|
||||
@ -167,6 +156,7 @@
|
||||
{{/requiredParamCount}}
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"{{httpMethod}}"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
|
@ -202,11 +202,9 @@ class ApiClient(object):
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = {obj.attribute_map[key[1:]]: val
|
||||
for key, val in iteritems(obj.__dict__)
|
||||
if key != 'swagger_types'
|
||||
and key != 'attribute_map'
|
||||
and val is not None}
|
||||
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
|
||||
for attr, _ in iteritems(obj.swagger_types)
|
||||
if getattr(obj, attr) is not None}
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in iteritems(obj_dict)}
|
||||
|
@ -23,9 +23,9 @@ import urllib3
|
||||
try:
|
||||
import httplib
|
||||
except ImportError:
|
||||
# python3
|
||||
# for python3
|
||||
import http.client as httplib
|
||||
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
|
@ -86,18 +86,17 @@ class {{classname}}(object):
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
value
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
|
@ -2,6 +2,7 @@ package Java
|
||||
|
||||
import io.swagger.codegen.languages.JavaClientCodegen
|
||||
import io.swagger.models._
|
||||
import io.swagger.models.parameters._
|
||||
import io.swagger.models.properties._
|
||||
import io.swagger.util.Json
|
||||
import org.junit.runner.RunWith
|
||||
@ -382,7 +383,6 @@ class JavaModelTest2 extends FlatSpec with Matchers {
|
||||
cm.vars.size should be(1)
|
||||
|
||||
val vars = cm.vars
|
||||
Json.prettyPrint(vars.get(0))
|
||||
vars.get(0).baseName should be("_")
|
||||
vars.get(0).getter should be("getU")
|
||||
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).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.OAuth;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
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 {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
/**
|
||||
* 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.Type;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
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 {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00")
|
||||
public class User {
|
||||
|
||||
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.OAuth;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
@ -3,6 +3,7 @@ package io.swagger.client;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
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 {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,5 +1,6 @@
|
||||
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 {
|
||||
/**
|
||||
* 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.Type;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class TypeRef<T> {
|
||||
private final Type type;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
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 {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,6 +5,7 @@ import io.swagger.client.Pair;
|
||||
import java.util.Map;
|
||||
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 {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
|
@ -172,6 +172,7 @@ extern NSString *const SWGResponseObjectErrorKey;
|
||||
*
|
||||
* @param path Request url.
|
||||
* @param method Request method.
|
||||
* @param pathParams Request path parameters.
|
||||
* @param queryParams Request query parameters.
|
||||
* @param body Request body.
|
||||
* @param headerParams Request header parameters.
|
||||
@ -184,6 +185,7 @@ extern NSString *const SWGResponseObjectErrorKey;
|
||||
*/
|
||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
pathParams:(NSDictionary *) pathParams
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
formParams:(NSDictionary *) formParams
|
||||
files:(NSDictionary *) files
|
||||
@ -195,4 +197,11 @@ extern NSString *const SWGResponseObjectErrorKey;
|
||||
responseType:(NSString *) responseType
|
||||
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
|
||||
|
@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int);
|
||||
|
||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||
method: (NSString*) method
|
||||
pathParams: (NSDictionary *) pathParams
|
||||
queryParams: (NSDictionary*) queryParams
|
||||
formParams: (NSDictionary *) formParams
|
||||
files: (NSDictionary *) files
|
||||
@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int);
|
||||
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
|
||||
[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;
|
||||
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams];
|
||||
if ([pathWithQueryParams hasPrefix:@"/"]) {
|
||||
pathWithQueryParams = [pathWithQueryParams substringFromIndex:1];
|
||||
}
|
||||
@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int);
|
||||
}
|
||||
}
|
||||
|
||||
// request cache
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
}
|
||||
if(offlineState) {
|
||||
NSLog(@"%@ cache forced", path);
|
||||
NSLog(@"%@ cache forced", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||
}
|
||||
else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) {
|
||||
NSLog(@"%@ cache enabled", path);
|
||||
NSLog(@"%@ cache enabled", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
|
||||
}
|
||||
else {
|
||||
NSLog(@"%@ cache disabled", path);
|
||||
NSLog(@"%@ cache disabled", resourcePath);
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||
}
|
||||
|
||||
@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int);
|
||||
*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
|
||||
|
@ -7,8 +7,8 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
#import "SWGTag.h"
|
||||
#import "SWGCategory.h"
|
||||
#import "SWGTag.h"
|
||||
|
||||
|
||||
@protocol SWGPet
|
||||
|
@ -80,7 +80,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -115,27 +116,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"PUT"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -172,7 +158,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -207,27 +194,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -264,7 +236,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -310,6 +283,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -346,7 +320,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -392,6 +367,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -433,8 +409,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -462,7 +441,7 @@
|
||||
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
|
||||
NSArray *authSettings = @[@"petstore_auth", @"api_key"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
@ -474,6 +453,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -521,8 +501,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -614,8 +602,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -657,6 +648,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"DELETE"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -704,8 +696,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -741,7 +736,9 @@
|
||||
|
||||
|
||||
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
if (additionalMetadata) {
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -753,6 +750,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
|
@ -77,7 +77,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -117,6 +118,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -153,7 +155,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -188,27 +191,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -250,8 +238,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -291,6 +282,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -332,8 +324,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -373,6 +368,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"DELETE"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
|
@ -80,7 +80,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -115,27 +116,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -172,7 +158,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -207,27 +194,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -264,7 +236,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -299,27 +272,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"POST"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -359,7 +317,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -407,6 +366,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -440,7 +400,8 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
@ -480,6 +441,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -521,8 +483,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -562,6 +527,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"GET"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -606,8 +572,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -642,27 +611,12 @@
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
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
|
||||
method: @"PUT"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
@ -704,8 +658,11 @@
|
||||
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
||||
[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];
|
||||
@ -745,6 +702,7 @@
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: resourcePath
|
||||
method: @"DELETE"
|
||||
pathParams: pathParams
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
|
@ -202,11 +202,9 @@ class ApiClient(object):
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = {obj.attribute_map[key[1:]]: val
|
||||
for key, val in iteritems(obj.__dict__)
|
||||
if key != 'swagger_types'
|
||||
and key != 'attribute_map'
|
||||
and val is not None}
|
||||
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
|
||||
for attr, _ in iteritems(obj.swagger_types)
|
||||
if getattr(obj, attr) is not None}
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in iteritems(obj_dict)}
|
||||
|
@ -23,9 +23,9 @@ import urllib3
|
||||
try:
|
||||
import httplib
|
||||
except ImportError:
|
||||
# python3
|
||||
# for python3
|
||||
import http.client as httplib
|
||||
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
|
@ -97,18 +97,17 @@ class Category(object):
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
value
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
result[attr] = value
|
||||
|
||||
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