Merge pull request #2 from ktjn/master

fix testcases
This commit is contained in:
Justus Thorvaldsson 2016-03-03 06:55:23 +01:00
commit d89deba96c
44 changed files with 1189 additions and 802 deletions

View File

@ -45,7 +45,7 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit
- [Ruby Sinatra](#ruby-sinatra) - [Ruby Sinatra](#ruby-sinatra)
- [Scala Scalatra](#scala-scalatra) - [Scala Scalatra](#scala-scalatra)
- [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118) - [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118)
- [Java JAX-RS (Apache CXF 3)](#java-jax-rs-apache-cxf-3) - [Java JAX-RS (Apache CXF 2 / 3)](#java-jax-rs-apache-cxf-2--3)
- [Java Spring MVC](#java-spring-mvc) - [Java Spring MVC](#java-spring-mvc)
- [Haskell Servant](#haskell-servant) - [Haskell Servant](#haskell-servant)
- [ASP.NET 5 Web API](#aspnet-5-web-api) - [ASP.NET 5 Web API](#aspnet-5-web-api)
@ -619,7 +619,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-o samples/server/petstore/jaxrs-jersey -o samples/server/petstore/jaxrs-jersey
``` ```
### Java JAX-RS (Apache CXF 3) ### Java JAX-RS (Apache CXF 2 / 3)
``` ```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
@ -628,6 +628,23 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-o samples/server/petstore/jaxrs-cxf -o samples/server/petstore/jaxrs-cxf
``` ```
This Codegen only generate a minimalist server stub. You must add the CXF dependency to your classpath (eg: with Maven)
If you are using CXF v2.x, you must provided a custom ```ResourceComparator``` class. This class will help CXF to choose the good resource interface for mapping an incomming request. The default behavior of CXF v2.x is not correct when many resources interface have the same global path.
See: See http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Customselectionbetweenmultipleresources
You can found this class here: https://github.com/hiveship/CXF2-resource-comparator/blob/master/src/main/java/CXFInterfaceComparator.java
TODO: This class could be directly generated by the Codegen.
You must register this class into your JAX-RS configuration file:
```xml
<jaxrs:resourceComparator>
<bean class="your.package.CXFInterfaceComparator"/>
</jaxrs:resourceComparator>
```
This is no longer necessary if you are using CXF >=v3.x
### Java Spring MVC ### Java Spring MVC
``` ```

View File

@ -343,7 +343,7 @@ public class DefaultCodegen {
} }
/** /**
* Return the capitalized file name of the model test * Return the capitalized file name of the model
* *
* @param name the model name * @param name the model name
* @return the file name of the model * @return the file name of the model

View File

@ -2,12 +2,15 @@
package io.swagger.codegen.languages; package io.swagger.codegen.languages;
import java.io.File; import java.io.File;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.swagger.codegen.CliOption; import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenProperty;
import io.swagger.models.Operation; import io.swagger.models.Operation;
public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
@ -15,7 +18,7 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
public JavaCXFServerCodegen() public JavaCXFServerCodegen()
{ {
super(); super();
supportsInheritance = true;
sourceFolder = "src/gen/java"; sourceFolder = "src/gen/java";
invokerPackage = "io.swagger.api"; invokerPackage = "io.swagger.api";
artifactId = "swagger-jaxrs-server"; artifactId = "swagger-jaxrs-server";
@ -28,6 +31,11 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
additionalProperties.put("title", title); additionalProperties.put("title", title);
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "javax.xml.datatype.XMLGregorianCalendar"); // Map DateTime fields to Java standart class 'XMLGregorianCalendar'
importMapping.put("LocalDate", "org.joda.time.LocalDate");
super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf";
for ( int i = 0; i < cliOptions.size(); i++ ) { for ( int i = 0; i < cliOptions.size(); i++ ) {
@ -37,6 +45,15 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
} }
} }
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);
Map<String, String> supportedLibraries = new LinkedHashMap<String,String>();
supportedLibraries.put(DEFAULT_LIBRARY, "CXF");
library.setEnum(supportedLibraries);
cliOptions.add(library);
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
cliOptions.add(new CliOption("title", "a title describing the application")); cliOptions.add(new CliOption("title", "a title describing the application"));
} }
@ -46,11 +63,11 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
{ {
super.processOpts(); super.processOpts();
sourceFolder = "gen" + File.separator + "java"; sourceFolder = "gen" + File.separator + "java";
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
modelTemplateFiles.clear(); //TODO
modelTemplateFiles.put("entityModel.mustache", ".java"); //final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
//supportingFiles.add(new SupportingFile("CXF2InterfaceComparator.mustache", invokerFolder, "CXF2InterfaceComparator.java"));
supportingFiles.clear();
} }
@Override @Override
@ -59,13 +76,23 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
return "jaxrs-cxf"; return "jaxrs-cxf";
} }
@Override @Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) { public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
super.addOperationToGroup(tag, resourcePath, operation, co, operations); super.addOperationToGroup(tag, resourcePath, operation, co, operations);
co.subresourceOperation = !co.path.isEmpty(); co.subresourceOperation = !co.path.isEmpty();
} }
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
model.imports.remove("ApiModelProperty");
model.imports.remove("ApiModel");
model.imports.remove("JsonSerialize");
model.imports.remove("ToStringSerializer");
model.imports.remove("JsonValue");
model.imports.remove("JsonProperty");
}
@Override @Override
public String getHelp() public String getHelp()
{ {

View File

@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.*; import java.util.*;
public class JavaInflectorServerCodegen extends JavaClientCodegen implements CodegenConfig { public class JavaInflectorServerCodegen extends JavaClientCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(JavaInflectorServerCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(JavaInflectorServerCodegen.class);

View File

@ -85,6 +85,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
defaultIncludes = new HashSet<String>( defaultIncludes = new HashSet<String>(
Arrays.asList( Arrays.asList(
"NSDate", "NSDate",
"NSURL", // for file
"Array", "Array",
"Dictionary", "Dictionary",
"Set", "Set",
@ -231,13 +232,57 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
String type = null; String type = null;
if (typeMapping.containsKey(swaggerType)) { if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType); type = typeMapping.get(swaggerType);
if (languageSpecificPrimitives.contains(type)) if (languageSpecificPrimitives.contains(type) || defaultIncludes.contains(type))
return toModelName(type); return type;
} else } else
type = swaggerType; type = swaggerType;
return toModelName(type); return toModelName(type);
} }
/**
* Output the proper model name (capitalized)
*
* @param name the name of the model
* @return capitalized model name
*/
@Override
public String toModelName(String name) {
name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final"
if (!StringUtils.isEmpty(modelNameSuffix)) { // set model suffix
name = name + "_" + modelNameSuffix;
}
if (!StringUtils.isEmpty(modelNamePrefix)) { // set model prefix
name = modelNamePrefix + "_" + name;
}
// camelize the model name
// phone_number => PhoneNumber
name = camelize(name);
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = "Object" + name;
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
return modelName;
}
return name;
}
/**
* Return the capitalized file name of the model
*
* @param name the model name
* @return the file name of the model
*/
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
@Override @Override
public String toDefaultValue(Property p) { public String toDefaultValue(Property p) {
// nil // nil
@ -304,17 +349,21 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String toOperationId(String operationId) { public String toOperationId(String operationId) {
// throw exception if method name is empty operationId = camelize(sanitizeName(operationId), true);
// throw exception if method name is empty. This should not happen but keep the check just in case
if (StringUtils.isEmpty(operationId)) { if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed"); throw new RuntimeException("Empty method name (operationId) not allowed");
} }
// method name cannot use reserved keyword, e.g. return // method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) { if (isReservedWord(operationId)) {
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); String newOperationId = camelize(("call_" + operationId), true);
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
return newOperationId;
} }
return camelize(sanitizeName(operationId), true); return operationId;
} }
@Override @Override

View File

@ -0,0 +1,120 @@
package {{package}};
import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
import org.apache.cxf.jaxrs.ext.ResourceComparator;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.message.Message;
/**
* This class only help CXF to decide which resource interface is more suitable. It used Java reflexion to iterate over Java methods but it *DO NOT* select the target method.
*/
public class CXFInterfaceComparator implements ResourceComparator {
private static final Logger LOGGER = LoggerFactory.getLogger(CXFInterfaceComparator.class);
@Override
public int compare(ClassResourceInfo cri1, ClassResourceInfo cri2, Message message) {
String requestVerb = (String) message.get(Message.HTTP_REQUEST_METHOD);
String requestURI = (String) message.get(Message.REQUEST_URI);
String requestPath = requestURI.replace((String) message.get(Message.BASE_PATH), "");
// remove "/"at the end of requestPath if present
if (requestPath.endsWith("/")){
requestPath = requestPath.substring(0, requestPath.length()-1);
}
if (analyseInterface(cri1, requestPath, requestVerb)) {
return -1; // Indicate that 'cri1' interface should be preferred
} else if (analyseInterface(cri2, requestPath, requestVerb)) {
return 1; // Indicate that 'cri2' interface should be preferred
} else {
return 0; // Nothing match, leave CXF decision
}
}
/**
* Analyse each methods provided to check if there is a match with the
* message request path and request HTTP verb.
*
* @param cri
* the interface to be analysed
* @param requestPath
* the path of the request. Do not contains the host and base
* path
* @return true if a method match the request, false otherwise
*/
private static boolean analyseInterface(ClassResourceInfo cri, String requestPath, String requestVerb) {
assert cri.getServiceClass() != null;
assert cri.getServiceClass().getInterfaces() != null;
assert cri.getServiceClass().getInterfaces()[0] != null;
assert cri.getServiceClass().getInterfaces()[0].getMethods().length > 0;
Method[] methods = cri.getServiceClass().getInterfaces()[0].getMethods();
// Java reflexion. Check all the methods of an interface.
for (Method method : methods) {
Path pathAnnotation = method.getAnnotation(javax.ws.rs.Path.class);
if (pathAnnotation != null && pathAnnotation.value() != null) {
String pathValue = pathAnnotation.value();
String methodHttpVerb = getMethodHttpVerb(method);
// Always authorize OPTIONS request if the path is matching a method declaration
if (requestVerb.equals(HttpMethod.OPTIONS) && match(pathValue,requestPath)) {
return true;
}
// Also check the HTTP verb since a single path can be match do multiple request, depending of the HTTP request verb.
if (requestVerb.equals(methodHttpVerb) && match(pathValue, requestPath)) {
return true;
}
}
}
return false;
}
private static String getMethodHttpVerb(Method method) {
if (method.getAnnotation(javax.ws.rs.POST.class) != null) {
return HttpMethod.POST;
} else if (method.getAnnotation(javax.ws.rs.GET.class) != null) {
return HttpMethod.GET;
} else if (method.getAnnotation(javax.ws.rs.PUT.class) != null) {
return HttpMethod.PUT;
} else if (method.getAnnotation(javax.ws.rs.OPTIONS.class) != null) {
return HttpMethod.OPTIONS;
} else if (method.getAnnotation(javax.ws.rs.DELETE.class) != null) {
return HttpMethod.DELETE;
} else if (method.getAnnotation(javax.ws.rs.HEAD.class) != null) {
return HttpMethod.HEAD;
}
assert false;
return null;
}
/**
* Check whether if the pathValue match with the requestPath parameter.
* Every path params are considered to be declared as '{param}'. The tokens to start and close path params declaration are '{' and '}'.
*
* @param valueFromAnnotation
* @param valueFromRequest
* @return true if there is a match, false otherwise
*/
private static boolean match(String valueFromAnnotation, String valueFromRequest) {
String patternFinal = valueFromAnnotation.replaceAll("\\{(.*?)\\}", "([^/]*)").replace("/", "\\/");
Matcher matcher = Pattern.compile(patternFinal).matcher(valueFromRequest);
if (matcher.matches()) {
return true;
}
return false;
}
@Override
public int compare(OperationResourceInfo ori1, OperationResourceInfo ori2, Message message) {
return 0; // Leave CXF decision
}
}

View File

@ -6,7 +6,7 @@ package {{package}};
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("{{contextPath}}") @Path("/")
public interface {{classname}} { public interface {{classname}} {
{{#operations}} {{#operations}}
{{#operation}} {{#operation}}
@ -14,8 +14,7 @@ public interface {{classname}} {
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#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}}
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}});
{{/hasMore}}{{/allParams}});
{{/operation}} {{/operation}}
} }
{{/operations}} {{/operations}}

View File

@ -1,51 +0,0 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import javax.xml.bind.annotation.XmlRootElement;
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
@XmlRootElement(name="{{classname}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}
{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@JsonProperty("{{name}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
{{/vars}}sb.append("}\n");
return sb.toString();
}
}
{{/model}}
{{/models}}

View File

@ -0,0 +1,16 @@
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="{{classname}}")
@XmlEnum
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/allowableValues}}
public String value() {
return name();
}
public static {{classname}} fromValue(String v) {
return valueOf(v);
}
}

View File

@ -1,3 +0,0 @@
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
}

View File

@ -3,13 +3,12 @@ package {{package}};
{{#imports}}import {{import}}; {{#imports}}import {{import}};
{{/imports}} {{/imports}}
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
{{#models}} {{#models}}
{{#model}}{{#description}} {{#model}}{{#description}}
/** /**
* {{description}} * {{description}}
**/{{/description}} **/{{/description}}
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}} {{#isEnum}}{{>enumClass}}{{/isEnum}}
{{^isEnum}}{{>pojo}}{{/isEnum}} {{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}} {{/model}}
{{/models}} {{/models}}

View File

@ -0,0 +1,57 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
{{#hasVars}} @XmlType(name = "{{classn,ame}}", propOrder =
{ {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}}
}){{/hasVars}}
{{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}}
{{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}}
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}}sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -4,6 +4,8 @@ package {{packageName}}
import ( import (
"strings" "strings"
"fmt" "fmt"
"encoding/json"
"errors"
"github.com/dghubble/sling" "github.com/dghubble/sling"
{{#imports}} "{{import}}" {{#imports}} "{{import}}"
{{/imports}} {{/imports}}
@ -68,16 +70,39 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
{{#hasBodyParam}}{{#bodyParams}}// body params {{#hasBodyParam}}{{#bodyParams}}// body params
_sling = _sling.BodyJSON({{paramName}}) _sling = _sling.BodyJSON({{paramName}})
{{/bodyParams}}{{/hasBodyParam}} {{/bodyParams}}{{/hasBodyParam}}
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
{{#returnType}} response := new({{returnType}}) // We use this map (below) so that any arbitrary error JSON can be handled.
_, err := _sling.ReceiveSuccess(response) // FIXME: This is in the absence of this Go generator honoring the non-2xx
//fmt.Println("{{operationId}} response: ", response, resp, err) // response (error) models, which needs to be implemented at some point.
return *response, err var failurePayload map[string]interface{}
{{/returnType}}{{^returnType}}
_, err := _sling.ReceiveSuccess(nil) httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload)
//fmt.Println("{{operationId}} response: void, ", resp, err)
return err if err == nil {
{{/returnType}} // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error)
if failurePayload != nil {
// If the failurePayload is present, there likely was some kind of non-2xx status
// returned (and a JSON payload error present)
var str []byte
str, err = json.Marshal(failurePayload)
if err == nil { // For safety, check for an error marshalling... probably superfluous
// This will return the JSON error body as a string
err = errors.New(string(str))
}
} else {
// So, there was no network-type error, and nothing in the failure payload,
// but we should still check the status code
if httpResponse == nil {
// This should never happen...
err = errors.New("No HTTP Response received.")
} else if code := httpResponse.StatusCode; 200 > code || code > 299 {
err = errors.New("HTTP Error: " + string(httpResponse.StatusCode))
}
}
}
return {{#returnType}}*successPayload, {{/returnType}}err
} }
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}

View File

@ -9,6 +9,8 @@ using IO.Swagger.Model;
using IO.Swagger.Client; using IO.Swagger.Client;
using System.Reflection; using System.Reflection;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]
@ -66,3 +68,5 @@ namespace IO.Swagger.Test
} }
} }

View File

@ -9,6 +9,8 @@ using IO.Swagger.Model;
using IO.Swagger.Client; using IO.Swagger.Client;
using System.Reflection; using System.Reflection;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]
@ -102,3 +104,5 @@ namespace IO.Swagger.Test
} }
} }

View File

@ -11,6 +11,7 @@ using IO.Swagger.Client;
using IO.Swagger.Api; using IO.Swagger.Api;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]

View File

@ -9,6 +9,8 @@ using IO.Swagger.Model;
using IO.Swagger.Client; using IO.Swagger.Client;
using System.Reflection; using System.Reflection;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]
@ -102,3 +104,5 @@ namespace IO.Swagger.Test
} }
} }

View File

@ -11,6 +11,7 @@ using IO.Swagger.Client;
using IO.Swagger.Api; using IO.Swagger.Api;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]

View File

@ -9,6 +9,8 @@ using IO.Swagger.Model;
using IO.Swagger.Client; using IO.Swagger.Client;
using System.Reflection; using System.Reflection;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]
@ -66,3 +68,5 @@ namespace IO.Swagger.Test
} }
} }

View File

@ -11,6 +11,7 @@ using IO.Swagger.Client;
using IO.Swagger.Api; using IO.Swagger.Api;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]

View File

@ -9,6 +9,8 @@ using IO.Swagger.Model;
using IO.Swagger.Client; using IO.Swagger.Client;
using System.Reflection; using System.Reflection;
namespace IO.Swagger.Test namespace IO.Swagger.Test
{ {
[TestFixture] [TestFixture]
@ -120,3 +122,5 @@ namespace IO.Swagger.Test
} }
} }

View File

@ -7,6 +7,7 @@ using RestSharp;
using IO.Swagger.Client; using IO.Swagger.Client;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Api namespace IO.Swagger.Api
{ {
@ -1308,12 +1309,6 @@ namespace IO.Swagger.Api
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
@ -1321,6 +1316,12 @@ namespace IO.Swagger.Api
{ {
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
} }
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request // make the HTTP request
@ -1401,13 +1402,6 @@ namespace IO.Swagger.Api
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
@ -1416,6 +1410,13 @@ namespace IO.Swagger.Api
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
} }
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request // make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
@ -2037,12 +2038,6 @@ namespace IO.Swagger.Api
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
@ -2050,6 +2045,12 @@ namespace IO.Swagger.Api
{ {
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
} }
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request // make the HTTP request
@ -2130,13 +2131,6 @@ namespace IO.Swagger.Api
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
@ -2145,6 +2139,13 @@ namespace IO.Swagger.Api
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
} }
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request // make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,

View File

@ -7,6 +7,7 @@ using RestSharp;
using IO.Swagger.Client; using IO.Swagger.Client;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Api namespace IO.Swagger.Api
{ {
@ -903,18 +904,18 @@ namespace IO.Swagger.Api
// authentication (test_api_key_header) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
{
localVarHeaderParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
}
// authentication (test_api_key_query) required // authentication (test_api_key_query) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query"))) if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query")))
{ {
localVarQueryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query"); localVarQueryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query");
} }
// authentication (test_api_key_header) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
{
localVarHeaderParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
}
// make the HTTP request // make the HTTP request
@ -995,13 +996,6 @@ namespace IO.Swagger.Api
// authentication (test_api_key_header) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
{
localVarHeaderParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
}
// authentication (test_api_key_query) required // authentication (test_api_key_query) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query"))) if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query")))
@ -1009,6 +1003,13 @@ namespace IO.Swagger.Api
localVarQueryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query"); localVarQueryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query");
} }
// authentication (test_api_key_header) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
{
localVarHeaderParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
}
// make the HTTP request // make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,

View File

@ -7,6 +7,7 @@ using RestSharp;
using IO.Swagger.Client; using IO.Swagger.Client;
using IO.Swagger.Model; using IO.Swagger.Model;
namespace IO.Swagger.Api namespace IO.Swagger.Api
{ {

View File

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model namespace IO.Swagger.Model
{ {
/// <summary> /// <summary>
@ -20,6 +22,7 @@ namespace IO.Swagger.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Category" /> class. /// Initializes a new instance of the <see cref="Category" /> class.
/// Initializes a new instance of the <see cref="Category" />class.
/// </summary> /// </summary>
/// <param name="Id">Id.</param> /// <param name="Id">Id.</param>
/// <param name="Name">Name.</param> /// <param name="Name">Name.</param>
@ -126,4 +129,6 @@ namespace IO.Swagger.Model
} }
} }
} }

View File

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model namespace IO.Swagger.Model
{ {
/// <summary> /// <summary>
@ -36,10 +38,11 @@ namespace IO.Swagger.Model
/// </summary> /// </summary>
/// <value>Order Status</value> /// <value>Order Status</value>
[DataMember(Name="status", EmitDefaultValue=true)] [DataMember(Name="status", EmitDefaultValue=true)]
public StatusEnum Status { get; set; } public StatusEnum? Status { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Order" /> class. /// Initializes a new instance of the <see cref="Order" /> class.
/// Initializes a new instance of the <see cref="Order" />class.
/// </summary> /// </summary>
/// <param name="PetId">PetId.</param> /// <param name="PetId">PetId.</param>
/// <param name="Quantity">Quantity.</param> /// <param name="Quantity">Quantity.</param>
@ -47,7 +50,7 @@ namespace IO.Swagger.Model
/// <param name="Status">Order Status.</param> /// <param name="Status">Order Status.</param>
/// <param name="Complete">Complete.</param> /// <param name="Complete">Complete.</param>
public Order(long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, string Status = null, bool? Complete = null) public Order(long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, StatusEnum? Status = null, bool? Complete = null)
{ {
this.PetId = PetId; this.PetId = PetId;
this.Quantity = Quantity; this.Quantity = Quantity;
@ -206,4 +209,6 @@ namespace IO.Swagger.Model
} }
} }
} }

View File

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model namespace IO.Swagger.Model
{ {
/// <summary> /// <summary>
@ -36,10 +38,11 @@ namespace IO.Swagger.Model
/// </summary> /// </summary>
/// <value>pet status in the store</value> /// <value>pet status in the store</value>
[DataMember(Name="status", EmitDefaultValue=true)] [DataMember(Name="status", EmitDefaultValue=true)]
public StatusEnum Status { get; set; } public StatusEnum? Status { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Pet" /> class. /// Initializes a new instance of the <see cref="Pet" /> class.
/// Initializes a new instance of the <see cref="Pet" />class.
/// </summary> /// </summary>
/// <param name="Id">Id.</param> /// <param name="Id">Id.</param>
/// <param name="Category">Category.</param> /// <param name="Category">Category.</param>
@ -48,7 +51,7 @@ namespace IO.Swagger.Model
/// <param name="Tags">Tags.</param> /// <param name="Tags">Tags.</param>
/// <param name="Status">pet status in the store.</param> /// <param name="Status">pet status in the store.</param>
public Pet(long? Id = null, Category Category = null, string Name = null, List<string> PhotoUrls = null, List<Tag> Tags = null, string Status = null) public Pet(long? Id = null, Category Category = null, string Name = null, List<string> PhotoUrls = null, List<Tag> Tags = null, StatusEnum? Status = null)
{ {
// to ensure "Name" is required (not null) // to ensure "Name" is required (not null)
if (Name == null) if (Name == null)
@ -224,4 +227,6 @@ namespace IO.Swagger.Model
} }
} }
} }

View File

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model namespace IO.Swagger.Model
{ {
/// <summary> /// <summary>
@ -20,6 +22,7 @@ namespace IO.Swagger.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Tag" /> class. /// Initializes a new instance of the <see cref="Tag" /> class.
/// Initializes a new instance of the <see cref="Tag" />class.
/// </summary> /// </summary>
/// <param name="Id">Id.</param> /// <param name="Id">Id.</param>
/// <param name="Name">Name.</param> /// <param name="Name">Name.</param>
@ -126,4 +129,6 @@ namespace IO.Swagger.Model
} }
} }
} }

View File

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model namespace IO.Swagger.Model
{ {
/// <summary> /// <summary>
@ -20,6 +22,7 @@ namespace IO.Swagger.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="User" /> class. /// Initializes a new instance of the <see cref="User" /> class.
/// Initializes a new instance of the <see cref="User" />class.
/// </summary> /// </summary>
/// <param name="Id">Id.</param> /// <param name="Id">Id.</param>
/// <param name="Username">Username.</param> /// <param name="Username">Username.</param>
@ -229,4 +232,6 @@ namespace IO.Swagger.Model
} }
} }
} }

View File

@ -49,7 +49,7 @@ namespace SwaggerClientTest.TestORder
Assert.AreEqual (1982, o.Id); Assert.AreEqual (1982, o.Id);
Assert.AreEqual (1020, o.PetId); Assert.AreEqual (1020, o.PetId);
Assert.AreEqual (1, o.Quantity); Assert.AreEqual (1, o.Quantity);
Assert.AreEqual ("placed", o.Status); Assert.AreEqual (Order.StatusEnum.Placed, o.Status);
Assert.AreEqual (true, o.Complete); Assert.AreEqual (true, o.Complete);
} }

View File

@ -24,7 +24,7 @@ namespace SwaggerClientTest.TestPet
Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" }); Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
p.Id = petId; p.Id = petId;
//p.Name = "Csharp test"; //p.Name = "Csharp test";
p.Status = "available"; p.Status = Pet.StatusEnum.Available;
// create Category object // create Category object
Category category = new Category(); Category category = new Category();
category.Id = 56; category.Id = 56;
@ -82,7 +82,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<Pet> (response, "Response is a Pet"); Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
Assert.AreEqual ("Csharp test", response.Name); Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual ("available", response.Status); Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array"); Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id); Assert.AreEqual (petId, response.Tags [0].Id);
@ -114,7 +114,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<Pet> (response, "Response is a Pet"); Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
Assert.AreEqual ("Csharp test", response.Name); Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual ("available", response.Status); Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array"); Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id); Assert.AreEqual (petId, response.Tags [0].Id);
@ -143,7 +143,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<Pet> (response, "Response is a Pet"); Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
Assert.AreEqual ("Csharp test", response.Name); Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual ("available", response.Status); Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array"); Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id); Assert.AreEqual (petId, response.Tags [0].Id);
@ -202,7 +202,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array"); Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual ("new form name", response.Name); Assert.AreEqual ("new form name", response.Name);
Assert.AreEqual ("pending", response.Status); Assert.AreEqual (Pet.StatusEnum.Pending, response.Status);
Assert.AreEqual (petId, response.Tags [0].Id); Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual (56, response.Category.Id); Assert.AreEqual (56, response.Category.Id);
@ -259,7 +259,7 @@ namespace SwaggerClientTest.TestPet
Pet p1 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} ); Pet p1 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} );
p1.Id = petId; p1.Id = petId;
//p1.Name = "Csharp test"; //p1.Name = "Csharp test";
p1.Status = "available"; p1.Status = Pet.StatusEnum.Available;
// create Category object // create Category object
Category category1 = new Category(); Category category1 = new Category();
category1.Id = 56; category1.Id = 56;
@ -278,7 +278,7 @@ namespace SwaggerClientTest.TestPet
Pet p2 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} ); Pet p2 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} );
p2.Id = petId; p2.Id = petId;
p2.Name = "Csharp test"; p2.Name = "Csharp test";
p2.Status = "available"; p2.Status = Pet.StatusEnum.Available;
// create Category object // create Category object
Category category2 = new Category(); Category category2 = new Category();
category2.Id = 56; category2.Id = 56;

View File

@ -166,20 +166,20 @@ public class PetAPI: APIBase {
- OAuth: - OAuth:
- type: oauth2 - type: oauth2
- name: petstore_auth - name: petstore_auth
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -188,21 +188,21 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -211,7 +211,7 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- parameter status: (query) Status values that need to be considered for query - parameter status: (query) Status values that need to be considered for query
@ -272,20 +272,20 @@ public class PetAPI: APIBase {
- OAuth: - OAuth:
- type: oauth2 - type: oauth2
- name: petstore_auth - name: petstore_auth
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -294,21 +294,21 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], } ], contentType=application/json}, {example=<Pet>
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -317,7 +317,7 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- parameter tags: (query) Tags to filter by - parameter tags: (query) Tags to filter by
@ -375,26 +375,26 @@ public class PetAPI: APIBase {
- GET /pet/{petId} - GET /pet/{petId}
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- OAuth:
- type: oauth2
- name: petstore_auth
- API Key: - API Key:
- type: apiKey api_key - type: apiKey api_key
- name: api_key - name: api_key
- examples: [{contentType=application/json, example={ - OAuth:
"photoUrls" : [ "aeiou" ], - type: oauth2
"name" : "doggie", - name: petstore_auth
- examples: [{example={
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], }, contentType=application/json}, {example=<Pet>
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -403,21 +403,21 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"photoUrls" : [ "aeiou" ], "tags" : [ {
"name" : "doggie", "id" : 123456789,
"name" : "aeiou"
} ],
"id" : 123456789, "id" : 123456789,
"category" : { "category" : {
"name" : "aeiou", "id" : 123456789,
"id" : 123456789 "name" : "aeiou"
}, },
"tags" : [ { "status" : "aeiou",
"name" : "aeiou", "name" : "doggie",
"id" : 123456789 "photoUrls" : [ "aeiou" ]
} ], }, contentType=application/json}, {example=<Pet>
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id> <id>123456</id>
<name>doggie</name> <name>doggie</name>
<photoUrls> <photoUrls>
@ -426,7 +426,7 @@ public class PetAPI: APIBase {
<tags> <tags>
</tags> </tags>
<status>string</status> <status>string</status>
</Pet>}] </Pet>, contentType=application/xml}]
- parameter petId: (path) ID of pet that needs to be fetched - parameter petId: (path) ID of pet that needs to be fetched
@ -678,14 +678,14 @@ public class PetAPI: APIBase {
- GET /pet/{petId}?testing_byte_array=true - GET /pet/{petId}?testing_byte_array=true
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- OAuth:
- type: oauth2
- name: petstore_auth
- API Key: - API Key:
- type: apiKey api_key - type: apiKey api_key
- name: api_key - name: api_key
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - OAuth:
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - type: oauth2
- name: petstore_auth
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
- parameter petId: (path) ID of pet that needs to be fetched - parameter petId: (path) ID of pet that needs to be fetched

View File

@ -55,36 +55,36 @@ public class StoreAPI: APIBase {
- API Key: - API Key:
- type: apiKey x-test_api_client_secret - type: apiKey x-test_api_client_secret
- name: test_api_client_secret - name: test_api_client_secret
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
} ]}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
} ], contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- examples: [{contentType=application/json, example=[ { - examples: [{example=[ {
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
} ]}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
} ], contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- parameter status: (query) Status value that needs to be considered for query - parameter status: (query) Status value that needs to be considered for query
@ -143,12 +143,12 @@ public class StoreAPI: APIBase {
- API Key: - API Key:
- type: apiKey api_key - type: apiKey api_key
- name: api_key - name: api_key
- examples: [{contentType=application/json, example={ - examples: [{example={
"key" : 123 "key" : 123
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] }, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"key" : 123 "key" : 123
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] }, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- returns: RequestBuilder<[String:Int]> - returns: RequestBuilder<[String:Int]>
*/ */
@ -208,36 +208,36 @@ public class StoreAPI: APIBase {
- API Key: - API Key:
- type: apiKey x-test_api_client_secret - type: apiKey x-test_api_client_secret
- name: test_api_client_secret - name: test_api_client_secret
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- parameter body: (body) order placed for purchasing the pet - parameter body: (body) order placed for purchasing the pet
@ -292,42 +292,42 @@ public class StoreAPI: APIBase {
- GET /store/order/{orderId} - GET /store/order/{orderId}
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- API Key:
- type: apiKey test_api_key_query (QUERY)
- name: test_api_key_query
- API Key: - API Key:
- type: apiKey test_api_key_header - type: apiKey test_api_key_header
- name: test_api_key_header - name: test_api_key_header
- examples: [{contentType=application/json, example={ - API Key:
"petId" : 123456789, - type: apiKey test_api_key_query (QUERY)
"quantity" : 123, - name: test_api_key_query
- examples: [{example={
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- examples: [{contentType=application/json, example={ - examples: [{example={
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789, "id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000", "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou" "status" : "aeiou",
}}, {contentType=application/xml, example=<Order> "quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id> <id>123456</id>
<petId>123456</petId> <petId>123456</petId>
<quantity>0</quantity> <quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate> <shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status> <status>string</status>
<complete>true</complete> <complete>true</complete>
</Order>}] </Order>, contentType=application/xml}]
- parameter orderId: (path) ID of pet that needs to be fetched - parameter orderId: (path) ID of pet that needs to be fetched

View File

@ -213,8 +213,8 @@ public class UserAPI: APIBase {
- GET /user/login - GET /user/login
- -
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- parameter username: (query) The user name for login - parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text - parameter password: (query) The password for login in clear text
@ -325,7 +325,7 @@ public class UserAPI: APIBase {
- GET /user/{username} - GET /user/{username}
- -
- examples: [{contentType=application/json, example={ - examples: [{example={
"id" : 1, "id" : 1,
"username" : "johnp", "username" : "johnp",
"firstName" : "John", "firstName" : "John",
@ -334,7 +334,7 @@ public class UserAPI: APIBase {
"password" : "-secret-", "password" : "-secret-",
"phone" : "0123456789", "phone" : "0123456789",
"userStatus" : 0 "userStatus" : 0
}}] }, contentType=application/json}]
- parameter username: (path) The name that needs to be fetched. Use user1 for testing. - parameter username: (path) The name that needs to be fetched. Use user1 for testing.

View File

@ -124,24 +124,6 @@ class Decoders {
fatalError("formatter failed to parse \(source)") fatalError("formatter failed to parse \(source)")
} }
// Decoder for [Order]
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
return Decoders.decode(clazz: [Order].self, source: source)
}
// Decoder for Order
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Order()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
return instance
}
// Decoder for [User] // Decoder for [User]
Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in
return Decoders.decode(clazz: [User].self, source: source) return Decoders.decode(clazz: [User].self, source: source)
@ -176,20 +158,6 @@ class Decoders {
} }
// Decoder for [Tag]
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
return Decoders.decode(clazz: [Tag].self, source: source)
}
// Decoder for Tag
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Tag()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
return instance
}
// Decoder for [Pet] // Decoder for [Pet]
Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in
return Decoders.decode(clazz: [Pet].self, source: source) return Decoders.decode(clazz: [Pet].self, source: source)
@ -207,6 +175,38 @@ class Decoders {
return instance return instance
} }
// Decoder for [Tag]
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
return Decoders.decode(clazz: [Tag].self, source: source)
}
// Decoder for Tag
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Tag()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
return instance
}
// Decoder for [Order]
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
return Decoders.decode(clazz: [Order].self, source: source)
}
// Decoder for Order
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Order()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
return instance
}
} }
} }
} }

View File

@ -6,7 +6,7 @@ import java.io.File;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("/v2") @Path("/")
public interface PetApi { public interface PetApi {
@PUT @PUT
@Path("/pet") @Path("/pet")
@ -37,28 +37,23 @@ public interface PetApi {
@Path("/pet/{petId}") @Path("/pet/{petId}")
@Consumes({ "application/x-www-form-urlencoded" }) @Consumes({ "application/x-www-form-urlencoded" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response updatePetWithForm(@PathParam("petId") String petId, public Response updatePetWithForm(@PathParam("petId") String petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status);
@Multipart(value = "name", required = false) String name,
@Multipart(value = "status", required = false) String status);
@DELETE @DELETE
@Path("/pet/{petId}") @Path("/pet/{petId}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response deletePet(@PathParam("petId") Long petId, public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
@HeaderParam("api_key") String apiKey);
@POST @POST
@Path("/pet/{petId}/uploadImage") @Path("/pet/{petId}/uploadImage")
@Consumes({ "multipart/form-data" }) @Consumes({ "multipart/form-data" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response uploadFile(@PathParam("petId") Long petId, public Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream,
@Multipart(value = "additionalMetadata", required = false) String additionalMetadata,
@Multipart(value = "file", required = false) InputStream fileInputStream,
@Multipart(value = "file" , required = false) Attachment fileDetail); @Multipart(value = "file" , required = false) Attachment fileDetail);
@GET @GET
@Path("/pet/{petId}?testing_byte_array=true") @Path("/pet/{petId}?testing_byte_array=true")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response getPetByIdWithByteArray(@PathParam("petId") Long petId); public Response petPetIdtestingByteArraytrueGet(@PathParam("petId") Long petId);
@POST @POST
@Path("/pet?testing_byte_array=true") @Path("/pet?testing_byte_array=true")
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })

View File

@ -6,7 +6,7 @@ import io.swagger.model.Order;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("/v2") @Path("/")
public interface StoreApi { public interface StoreApi {
@GET @GET
@Path("/store/inventory") @Path("/store/inventory")

View File

@ -1,12 +1,12 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.User; import io.swagger.model.User;
import java.util.*; import java.util.List;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("/v2") @Path("/")
public interface UserApi { public interface UserApi {
@POST @POST
@Path("/user") @Path("/user")
@ -27,8 +27,7 @@ public interface UserApi {
@Path("/user/login") @Path("/user/login")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response loginUser(@QueryParam("username") String username, public Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password);
@QueryParam("password") String password);
@GET @GET
@Path("/user/logout") @Path("/user/logout")
@ -43,8 +42,7 @@ public interface UserApi {
@Path("/user/{username}") @Path("/user/{username}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
public Response updateUser(@PathParam("username") String username, public Response updateUser(@PathParam("username") String username,User body);
User body);
@DELETE @DELETE
@Path("/user/{username}") @Path("/user/{username}")

View File

@ -1,13 +1,18 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Category") @XmlRootElement(name="Category")
public class Category { public class Category {
@ -20,7 +25,7 @@ public class Category {
/** /**
**/ **/
@JsonProperty("id")
public Long getId() { public Long getId() {
return id; return id;
} }
@ -28,10 +33,9 @@ public class Category {
this.id = id; this.id = id;
} }
/** /**
**/ **/
@JsonProperty("name")
public String getName() { public String getName() {
return name; return name;
} }
@ -40,15 +44,26 @@ public class Category {
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Category {\n"); sb.append("class Category {\n");
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(name).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}\n"); sb.append("}");
return sb.toString(); return sb.toString();
} }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,14 +1,18 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder =
{ "id", "petId", "quantity", "shipDate", "status", "complete"
})
@XmlRootElement(name="Order") @XmlRootElement(name="Order")
public class Order { public class Order {
@ -20,11 +24,25 @@ public class Order {
private Integer quantity = null; private Integer quantity = null;
private Date shipDate = null; private javax.xml.datatype.XMLGregorianCalendar shipDate = null;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="Order")
@XmlEnum
public enum Order {
{values=[placed, approved, delivered], enumVars=[{name=PLACED, value=placed}, {name=APPROVED, value=approved}, {name=DELIVERED, value=delivered}]},
public String value() {
return name();
}
public static Order fromValue(String v) {
return valueOf(v);
}
}
public enum StatusEnum {
placed, approved, delivered,
};
private StatusEnum status = null; private StatusEnum status = null;
private Boolean complete = null; private Boolean complete = null;
@ -32,7 +50,7 @@ public class Order {
/** /**
**/ **/
@JsonProperty("id")
public Long getId() { public Long getId() {
return id; return id;
} }
@ -40,10 +58,9 @@ public class Order {
this.id = id; this.id = id;
} }
/** /**
**/ **/
@JsonProperty("petId")
public Long getPetId() { public Long getPetId() {
return petId; return petId;
} }
@ -51,10 +68,9 @@ public class Order {
this.petId = petId; this.petId = petId;
} }
/** /**
**/ **/
@JsonProperty("quantity")
public Integer getQuantity() { public Integer getQuantity() {
return quantity; return quantity;
} }
@ -62,22 +78,20 @@ public class Order {
this.quantity = quantity; this.quantity = quantity;
} }
/** /**
**/ **/
@JsonProperty("shipDate")
public Date getShipDate() { public javax.xml.datatype.XMLGregorianCalendar getShipDate() {
return shipDate; return shipDate;
} }
public void setShipDate(Date shipDate) { public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) {
this.shipDate = shipDate; this.shipDate = shipDate;
} }
/** /**
* Order Status * Order Status
**/ **/
@JsonProperty("status")
public StatusEnum getStatus() { public StatusEnum getStatus() {
return status; return status;
} }
@ -85,10 +99,9 @@ public class Order {
this.status = status; this.status = status;
} }
/** /**
**/ **/
@JsonProperty("complete")
public Boolean getComplete() { public Boolean getComplete() {
return complete; return complete;
} }
@ -97,19 +110,30 @@ public class Order {
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Order {\n"); sb.append("class Order {\n");
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" petId: ").append(petId).append("\n"); sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
sb.append(" quantity: ").append(quantity).append("\n"); sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append(" shipDate: ").append(shipDate).append("\n"); sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
sb.append(" status: ").append(status).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" complete: ").append(complete).append("\n"); sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
sb.append("}\n"); sb.append("}");
return sb.toString(); return sb.toString();
} }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,16 +1,22 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.model.Category; import io.swagger.model.Category;
import io.swagger.model.Tag; import io.swagger.model.Tag;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder =
{ "id", "category", "name", "photoUrls", "tags", "status"
})
@XmlRootElement(name="Pet") @XmlRootElement(name="Pet")
public class Pet { public class Pet {
@ -26,15 +32,29 @@ public class Pet {
private List<Tag> tags = new ArrayList<Tag>(); private List<Tag> tags = new ArrayList<Tag>();
public enum StatusEnum { import javax.xml.bind.annotation.XmlEnum;
available, pending, sold, import javax.xml.bind.annotation.XmlType;
};
@XmlType(name="Pet")
@XmlEnum
public enum Pet {
{values=[available, pending, sold], enumVars=[{name=AVAILABLE, value=available}, {name=PENDING, value=pending}, {name=SOLD, value=sold}]},
public String value() {
return name();
}
public static Pet fromValue(String v) {
return valueOf(v);
}
}
private StatusEnum status = null; private StatusEnum status = null;
/** /**
**/ **/
@JsonProperty("id")
public Long getId() { public Long getId() {
return id; return id;
} }
@ -42,10 +62,9 @@ public class Pet {
this.id = id; this.id = id;
} }
/** /**
**/ **/
@JsonProperty("category")
public Category getCategory() { public Category getCategory() {
return category; return category;
} }
@ -53,10 +72,9 @@ public class Pet {
this.category = category; this.category = category;
} }
/** /**
**/ **/
@JsonProperty("name")
public String getName() { public String getName() {
return name; return name;
} }
@ -64,10 +82,9 @@ public class Pet {
this.name = name; this.name = name;
} }
/** /**
**/ **/
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() { public List<String> getPhotoUrls() {
return photoUrls; return photoUrls;
} }
@ -75,10 +92,9 @@ public class Pet {
this.photoUrls = photoUrls; this.photoUrls = photoUrls;
} }
/** /**
**/ **/
@JsonProperty("tags")
public List<Tag> getTags() { public List<Tag> getTags() {
return tags; return tags;
} }
@ -86,11 +102,10 @@ public class Pet {
this.tags = tags; this.tags = tags;
} }
/** /**
* pet status in the store * pet status in the store
**/ **/
@JsonProperty("status")
public StatusEnum getStatus() { public StatusEnum getStatus() {
return status; return status;
} }
@ -99,19 +114,30 @@ public class Pet {
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Pet {\n"); sb.append("class Pet {\n");
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" category: ").append(category).append("\n"); sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append(" name: ").append(name).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" photoUrls: ").append(photoUrls).append("\n"); sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
sb.append(" tags: ").append(tags).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
sb.append(" status: ").append(status).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append("}\n"); sb.append("}");
return sb.toString(); return sb.toString();
} }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,13 +1,18 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Tag") @XmlRootElement(name="Tag")
public class Tag { public class Tag {
@ -20,7 +25,7 @@ public class Tag {
/** /**
**/ **/
@JsonProperty("id")
public Long getId() { public Long getId() {
return id; return id;
} }
@ -28,10 +33,9 @@ public class Tag {
this.id = id; this.id = id;
} }
/** /**
**/ **/
@JsonProperty("name")
public String getName() { public String getName() {
return name; return name;
} }
@ -40,15 +44,26 @@ public class Tag {
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Tag {\n"); sb.append("class Tag {\n");
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(name).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}\n"); sb.append("}");
return sb.toString(); return sb.toString();
} }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,13 +1,18 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder =
{ "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"
})
@XmlRootElement(name="User") @XmlRootElement(name="User")
public class User { public class User {
@ -32,7 +37,7 @@ public class User {
/** /**
**/ **/
@JsonProperty("id")
public Long getId() { public Long getId() {
return id; return id;
} }
@ -40,10 +45,9 @@ public class User {
this.id = id; this.id = id;
} }
/** /**
**/ **/
@JsonProperty("username")
public String getUsername() { public String getUsername() {
return username; return username;
} }
@ -51,10 +55,9 @@ public class User {
this.username = username; this.username = username;
} }
/** /**
**/ **/
@JsonProperty("firstName")
public String getFirstName() { public String getFirstName() {
return firstName; return firstName;
} }
@ -62,10 +65,9 @@ public class User {
this.firstName = firstName; this.firstName = firstName;
} }
/** /**
**/ **/
@JsonProperty("lastName")
public String getLastName() { public String getLastName() {
return lastName; return lastName;
} }
@ -73,10 +75,9 @@ public class User {
this.lastName = lastName; this.lastName = lastName;
} }
/** /**
**/ **/
@JsonProperty("email")
public String getEmail() { public String getEmail() {
return email; return email;
} }
@ -84,10 +85,9 @@ public class User {
this.email = email; this.email = email;
} }
/** /**
**/ **/
@JsonProperty("password")
public String getPassword() { public String getPassword() {
return password; return password;
} }
@ -95,10 +95,9 @@ public class User {
this.password = password; this.password = password;
} }
/** /**
**/ **/
@JsonProperty("phone")
public String getPhone() { public String getPhone() {
return phone; return phone;
} }
@ -106,11 +105,10 @@ public class User {
this.phone = phone; this.phone = phone;
} }
/** /**
* User Status * User Status
**/ **/
@JsonProperty("userStatus")
public Integer getUserStatus() { public Integer getUserStatus() {
return userStatus; return userStatus;
} }
@ -119,21 +117,32 @@ public class User {
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class User {\n"); sb.append("class User {\n");
sb.append(" id: ").append(id).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" username: ").append(username).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" firstName: ").append(firstName).append("\n"); sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(lastName).append("\n"); sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" email: ").append(email).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" password: ").append(password).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" phone: ").append(phone).append("\n"); sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
sb.append(" userStatus: ").append(userStatus).append("\n"); sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
sb.append("}\n"); sb.append("}");
return sb.toString(); return sb.toString();
} }
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
}