Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328 2016-10-11 11:52:26 +08:00
commit a73ad79b9b
153 changed files with 4196 additions and 240 deletions

3
.gitignore vendored
View File

@ -143,3 +143,6 @@ samples/client/petstore/typescript-angular/**/typings
samples/client/petstore/typescript-fetch/**/dist/ samples/client/petstore/typescript-fetch/**/dist/
samples/client/petstore/typescript-fetch/**/typings samples/client/petstore/typescript-fetch/**/typings
# aspnet5
samples/server/petstore/aspnet5/.vs/

View File

@ -886,6 +886,7 @@ Here is a list of template creators:
* Java Spring Boot: @diyfr * Java Spring Boot: @diyfr
* JAX-RS RestEasy: @chameleon82 * JAX-RS RestEasy: @chameleon82
* JAX-RS CXF: @hiveship * JAX-RS CXF: @hiveship
* JAX-RS CXF (CDI): @nickcmaynard
* PHP Lumen: @abcsum * PHP Lumen: @abcsum
* PHP Slim: @jfastnacht * PHP Slim: @jfastnacht
* Ruby on Rails 5: @zlx * Ruby on Rails 5: @zlx

32
bin/flaskConnexion-python2.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l python-flask -o samples/server/petstore/flaskConnexion-python2 -DsupportPython2=true"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l python-flask -o samples/server/petstore/flaskConnexion-python2 -c bin/supportPython2.json"
java $JAVA_OPTS -Dservice -jar $executable $ags

View File

@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf-cdi -o samples/server/petstore/jaxrs-cxf-cdi -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags

3
bin/supportPython2.json Normal file
View File

@ -0,0 +1,3 @@
{
"supportPython2": true
}

View File

@ -9,10 +9,14 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import static java.util.UUID.randomUUID;
public class AspNet5ServerCodegen extends AbstractCSharpCodegen { public class AspNet5ServerCodegen extends AbstractCSharpCodegen {
protected String sourceFolder = "src" + File.separator + packageName; protected String sourceFolder = "src" + File.separator + packageName;
private final String packageGuid = "{" + randomUUID().toString().toUpperCase() + "}";
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected Logger LOGGER = LoggerFactory.getLogger(AspNet5ServerCodegen.class); protected Logger LOGGER = LoggerFactory.getLogger(AspNet5ServerCodegen.class);
@ -81,6 +85,8 @@ public class AspNet5ServerCodegen extends AbstractCSharpCodegen {
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
additionalProperties.put("packageGuid", packageGuid);
apiPackage = packageName + ".Controllers"; apiPackage = packageName + ".Controllers";
modelPackage = packageName + ".Models"; modelPackage = packageName + ".Models";

View File

@ -145,6 +145,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
} else { } else {
LOGGER.error("Unknown library option (-l/--library): " + getLibrary()); LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
} }
if (additionalProperties.containsKey("jackson") ) {
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
}
} }
private boolean usesAnyRetrofitLibrary() { private boolean usesAnyRetrofitLibrary() {

View File

@ -0,0 +1,53 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
import java.io.File;
public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen
{
public JavaJAXRSCXFCDIServerCodegen()
{
sourceFolder = "src" + File.separator + "gen" + File.separator + "java";
// Three API templates to support CDI injection
apiTemplateFiles.put("apiService.mustache", ".java");
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
// Use standard types
typeMapping.put("DateTime", "java.util.Date");
// Updated template directory
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
}
@Override
public String getName()
{
return "jaxrs-cxf-cdi";
}
@Override
public void processOpts()
{
super.processOpts();
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
// Reinstate JsonProperty
model.imports.add("JsonProperty");
}
@Override
public String getHelp()
{
return "Generates a Java JAXRS Server according to JAXRS 2.0 specification, assuming an Apache CXF runtime and a Java EE runtime with CDI enabled.";
}
}

View File

@ -104,6 +104,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java")); supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java")); supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java")); supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "RFC3339DateFormat.java"));
writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java")); writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml")); writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));

View File

@ -67,10 +67,12 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen {
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")); (sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
supportingFiles.add(new SupportingFile("StringUtil.mustache", supportingFiles.add(new SupportingFile("StringUtil.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "StringUtil.java")); (sourceFolder + '/' + invokerPackage).replace(".", "/"), "StringUtil.java"));
supportingFiles.add(new SupportingFile("JacksonConfig.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "JacksonConfig.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RFC3339DateFormat.java"));
if ("joda".equals(dateLibrary)) { if ("joda".equals(dateLibrary)) {
supportingFiles.add(new SupportingFile("JacksonConfig.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "JacksonConfig.java"));
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache",
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java")); (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache",

View File

@ -360,7 +360,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
return getSwaggerType(p) + "<NSString*, " + innerTypeDeclaration + "*>*"; return getSwaggerType(p) + "<NSString*, " + innerTypeDeclaration + "*>*";
} }
} }
return getSwaggerType(p) + "<NSString*, " + innerTypeDeclaration + ">*"; return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*";
} }
} else { } else {
String swaggerType = getSwaggerType(p); String swaggerType = getSwaggerType(p);

View File

@ -126,6 +126,8 @@ public class SpringCodegen extends AbstractJavaCodegen {
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java")); (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache", supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java")); (sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
supportingFiles.add(new SupportingFile("application.mustache", supportingFiles.add(new SupportingFile("application.mustache",
("src.main.resources").replace(".", java.io.File.separator), "application.properties")); ("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
} }
@ -136,6 +138,8 @@ public class SpringCodegen extends AbstractJavaCodegen {
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java")); (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache", supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java")); (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
supportingFiles.add(new SupportingFile("application.properties", supportingFiles.add(new SupportingFile("application.properties",
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties")); ("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
} }

View File

@ -40,7 +40,6 @@ import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import {{invokerPackage}}.auth.Authentication; import {{invokerPackage}}.auth.Authentication;
import {{invokerPackage}}.auth.HttpBasicAuth; import {{invokerPackage}}.auth.HttpBasicAuth;
@ -96,12 +95,7 @@ public class ApiClient {
} }
public static DateFormat buildDefaultDateFormat() { public static DateFormat buildDefaultDateFormat() {
// Use RFC3339 format for date and datetime. return new RFC3339DateFormat();
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat;
} }
/** /**

View File

@ -0,0 +1,21 @@
{{>licenseInfo}}
package {{invokerPackage}};
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -136,6 +136,7 @@ public class ApiClient {
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setDateFormat(new RFC3339DateFormat());
{{^java8}} {{^java8}}
objectMapper.registerModule(new JodaModule()); objectMapper.registerModule(new JodaModule());
{{/java8}} {{/java8}}

View File

@ -8,7 +8,6 @@ import java.nio.charset.Charset;
import java.util.*; import java.util.*;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import feign.codec.EncodeException; import feign.codec.EncodeException;
import feign.codec.Encoder; import feign.codec.Encoder;
@ -32,12 +31,8 @@ public class FormAwareEncoder implements Encoder {
public FormAwareEncoder(Encoder delegate) { public FormAwareEncoder(Encoder delegate) {
this.delegate = delegate; this.delegate = delegate;
// Use RFC3339 format for date and datetime. this.dateFormat = new RFC3339DateFormat();;
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try { try {
this.lineFeedBytes = LINE_FEED.getBytes(UTF_8); this.lineFeedBytes = LINE_FEED.getBytes(UTF_8);
this.boundaryBytes = BOUNDARY.getBytes(UTF_8); this.boundaryBytes = BOUNDARY.getBytes(UTF_8);

View File

@ -39,7 +39,6 @@ import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -70,14 +69,7 @@ public class ApiClient {
json = new JSON(); json = new JSON();
httpClient = buildHttpClient(debugging); httpClient = buildHttpClient(debugging);
// Use RFC3339 format for date and datetime. this.dateFormat = new RFC3339DateFormat();
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.json.setDateFormat((DateFormat) dateFormat.clone());
// Set default User-Agent. // Set default User-Agent.
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}"); setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}");

View File

@ -24,6 +24,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.setDateFormat(new RFC3339DateFormat());
{{#java8}} {{#java8}}
mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new JavaTimeModule());
{{/java8}} {{/java8}}

View File

@ -0,0 +1,19 @@
package {{apiPackage}};
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -0,0 +1 @@
{{#allowableValues}}allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{^values}}range=[{{#min}}{{.}}{{/min}}{{^min}}-infinity{{/min}}, {{#max}}{{.}}{{/max}}{{^max}}infinity{{/max}}]{{/values}}"{{/allowableValues}}

View File

@ -0,0 +1,55 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import {{package}}.{{classname}}Service;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.List;
@Path("/{{baseName}}")
@RequestScoped
@Api(description = "the {{baseName}} API")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{>generatedAnnotation}}
public class {{classname}} {
@Context SecurityContext securityContext;
@Inject {{classname}}Service delegate;
{{#operations}}
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}},
{{/hasMore}}{{/scopes}}
}{{/isOAuth}}){{#hasMore}},
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/allParams}}securityContext);
}
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,25 @@
package {{package}};
import {{package}}.*;
import {{modelPackage}}.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{>generatedAnnotation}}
{{#operations}}
public interface {{classname}}Service {
{{#operation}}
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext);
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,31 @@
package {{package}}.impl;
import {{package}}.*;
import {{modelPackage}}.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}}ServiceImpl implements {{classname}}Service {
{{#operation}}
@Override
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isBodyParam}}

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

@ -0,0 +1 @@
{{#isFormParam}}{{#notFile}}@Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream, @Multipart(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}

View File

@ -0,0 +1 @@
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")

View File

@ -0,0 +1 @@
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@ -0,0 +1,14 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
{{#isEnum}}{{>enumClass}}{{/isEnum}}
{{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1 @@
{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@ -0,0 +1,75 @@
import io.swagger.annotations.*;
import java.util.Objects;
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#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}}
**/
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
return true;{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/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 String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#defaultValue}}@DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@ -0,0 +1 @@
{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}InputStream {{paramName}}InputStream, Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}

View File

@ -0,0 +1 @@
{{#isHeaderParam}}{{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@ -0,0 +1 @@
{{#isPathParam}}{{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@ -0,0 +1 @@
{{#isQueryParam}}{{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -1,8 +1,10 @@
package {{apiPackage}}; package {{apiPackage}};
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import io.swagger.util.Json;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -11,9 +13,15 @@ import javax.ws.rs.ext.Provider;
@Provider @Provider
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public class JacksonJsonProvider extends JacksonJaxbJsonProvider { public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
private static ObjectMapper commonMapper = Json.mapper();
public JacksonJsonProvider() { public JacksonJsonProvider() {
super.setMapper(commonMapper);
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.registerModule(new JodaModule())
.setDateFormat(new RFC3339DateFormat());
setMapper(objectMapper);
} }
} }

View File

@ -20,24 +20,25 @@ public class JacksonConfig implements ContextResolver<ObjectMapper> {
public JacksonConfig() throws Exception { public JacksonConfig() throws Exception {
objectMapper = new ObjectMapper(); objectMapper = new ObjectMapper()
objectMapper.registerModule(new JodaModule() { .setDateFormat(new RFC3339DateFormat())
{ .registerModule(new JodaModule() {
addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) { {
@Override addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) {
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { @Override
jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().print(value)); public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
} jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().print(value));
}); }
addSerializer(LocalDate.class, new StdSerializer<LocalDate>(LocalDate.class) { });
@Override addSerializer(LocalDate.class, new StdSerializer<LocalDate>(LocalDate.class) {
public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { @Override
jgen.writeString(ISODateTimeFormat.date().print(value)); public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
} jgen.writeString(ISODateTimeFormat.date().print(value));
}); }
});
} }
}); });
} }
public ObjectMapper getContext(Class<?> arg0) { public ObjectMapper getContext(Class<?> arg0) {

View File

@ -0,0 +1,19 @@
package {{invokerPackage}};
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -1,3 +1,5 @@
springfox.documentation.swagger.v2.path=/api-docs springfox.documentation.swagger.v2.path=/api-docs
server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
server.port={{serverPort}} server.port={{serverPort}}
spring.jackson.date-format={{basePackage}}.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false

View File

@ -0,0 +1,20 @@
package {{basePackage}};
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -0,0 +1,20 @@
package {{configPackage}};
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -1,14 +1,21 @@
package {{configPackage}}; package {{configPackage}};
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.List;
{{>generatedAnnotation}} {{>generatedAnnotation}}
@Configuration @Configuration
@ComponentScan(basePackages = "{{apiPackage}}") @ComponentScan(basePackages = "{{apiPackage}}")
@ -51,4 +58,14 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
} }
} }
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat( new RFC3339DateFormat())
.build();
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
super.configureMessageConverters(converters);
}
} }

View File

@ -14,6 +14,7 @@ io.swagger.codegen.languages.JavaJerseyServerCodegen
io.swagger.codegen.languages.JavaCXFServerCodegen io.swagger.codegen.languages.JavaCXFServerCodegen
io.swagger.codegen.languages.JavaResteasyServerCodegen io.swagger.codegen.languages.JavaResteasyServerCodegen
io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen
io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen
io.swagger.codegen.languages.JavaInflectorServerCodegen io.swagger.codegen.languages.JavaInflectorServerCodegen
io.swagger.codegen.languages.JavascriptClientCodegen io.swagger.codegen.languages.JavascriptClientCodegen
io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
@ -53,4 +54,3 @@ io.swagger.codegen.languages.LumenServerCodegen
io.swagger.codegen.languages.GoServerCodegen io.swagger.codegen.languages.GoServerCodegen
io.swagger.codegen.languages.ErlangServerCodegen io.swagger.codegen.languages.ErlangServerCodegen
io.swagger.codegen.languages.UndertowCodegen io.swagger.codegen.languages.UndertowCodegen

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{{projectGuid}}</ProjectGuid> <ProjectGuid>{{packageGuid}}</ProjectGuid>
<RootNamespace>Sample</RootNamespace> <RootNamespace>{{packageName}}</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>

View File

@ -1,10 +1,7 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{815BE834-0656-4C12-84A4-43F2BA4B8BDE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
global.json = global.json global.json = global.json
@ -18,15 +15,12 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{packageGuid}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.Build.0 = Debug|Any CPU {{packageGuid}}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.ActiveCfg = Release|Any CPU {{packageGuid}}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.Build.0 = Release|Any CPU {{packageGuid}}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{{packageGuid}} = {815BE834-0656-4C12-84A4-43F2BA4B8BDE}
EndGlobalSection
EndGlobal EndGlobal

View File

@ -10,8 +10,14 @@ This example uses the [Connexion](https://github.com/zalando/connexion) library
To run the server, please execute the following: To run the server, please execute the following:
``` ```
{{#supportPython2}}
sudo pip install -U connexion # install Connexion from PyPI
python app.py
{{/supportPython2}}
{{^supportPython2}}
sudo pip3 install -U connexion # install Connexion from PyPI sudo pip3 install -U connexion # install Connexion from PyPI
python3 app.py python3 app.py
{{/supportPython2}}
``` ```
and open your browser to here: and open your browser to here:

View File

@ -1,4 +1,9 @@
{{#supportPython2}}
#!/usr/bin/env python
{{/supportPython2}}
{{^supportPython2}}
#!/usr/bin/env python3 #!/usr/bin/env python3
{{/supportPython2}}
import connexion import connexion

View File

@ -224,7 +224,7 @@ public class ObjcModelTest {
final CodegenProperty property1 = cm.vars.get(0); final CodegenProperty property1 = cm.vars.get(0);
Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.baseName, "children");
Assert.assertEquals(property1.complexType, "SWGChildren"); Assert.assertEquals(property1.complexType, "SWGChildren");
Assert.assertEquals(property1.datatype, "NSDictionary<NSString*, SWGChildren>*"); Assert.assertEquals(property1.datatype, "NSDictionary<SWGChildren>*");
Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "NSDictionary"); Assert.assertEquals(property1.baseType, "NSDictionary");
Assert.assertEquals(property1.containerType, "map"); Assert.assertEquals(property1.containerType, "map");

View File

@ -132,6 +132,7 @@ public class ApiClient {
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setDateFormat(new RFC3339DateFormat());
objectMapper.registerModule(new JodaModule()); objectMapper.registerModule(new JodaModule());
return objectMapper; return objectMapper;
} }

View File

@ -8,7 +8,6 @@ import java.nio.charset.Charset;
import java.util.*; import java.util.*;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import feign.codec.EncodeException; import feign.codec.EncodeException;
import feign.codec.Encoder; import feign.codec.Encoder;
@ -32,12 +31,8 @@ public class FormAwareEncoder implements Encoder {
public FormAwareEncoder(Encoder delegate) { public FormAwareEncoder(Encoder delegate) {
this.delegate = delegate; this.delegate = delegate;
// Use RFC3339 format for date and datetime. this.dateFormat = new RFC3339DateFormat();;
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try { try {
this.lineFeedBytes = LINE_FEED.getBytes(UTF_8); this.lineFeedBytes = LINE_FEED.getBytes(UTF_8);
this.boundaryBytes = BOUNDARY.getBytes(UTF_8); this.boundaryBytes = BOUNDARY.getBytes(UTF_8);

View File

@ -0,0 +1,44 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -58,7 +58,6 @@ import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import io.swagger.client.auth.Authentication; import io.swagger.client.auth.Authentication;
import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.HttpBasicAuth;
@ -109,12 +108,7 @@ public class ApiClient {
} }
public static DateFormat buildDefaultDateFormat() { public static DateFormat buildDefaultDateFormat() {
// Use RFC3339 format for date and datetime. return new RFC3339DateFormat();
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat;
} }
/** /**

View File

@ -0,0 +1,44 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -34,8 +34,8 @@ import io.swagger.client.Pair;
import io.swagger.client.model.Client; import io.swagger.client.model.Client;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.joda.time.DateTime;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -33,8 +33,8 @@ import io.swagger.client.model.*;
import io.swagger.client.Pair; import io.swagger.client.Pair;
import io.swagger.client.model.Pet; import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.ModelApiResponse; import io.swagger.client.model.ModelApiResponse;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -39,7 +39,6 @@ import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -70,14 +69,7 @@ public class ApiClient {
json = new JSON(); json = new JSON();
httpClient = buildHttpClient(debugging); httpClient = buildHttpClient(debugging);
// Use RFC3339 format for date and datetime. this.dateFormat = new RFC3339DateFormat();
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.json.setDateFormat((DateFormat) dateFormat.clone());
// Set default User-Agent. // Set default User-Agent.
setUserAgent("Swagger-Codegen/1.0.0/java"); setUserAgent("Swagger-Codegen/1.0.0/java");

View File

@ -19,6 +19,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.setDateFormat(new RFC3339DateFormat());
mapper.registerModule(new JodaModule()); mapper.registerModule(new JodaModule());
} }

View File

@ -0,0 +1,44 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -1,8 +1,11 @@
package io.swagger.client; package io.swagger.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.std.SqlDateSerializer;
import io.swagger.client.model.Order; import io.swagger.client.model.Order;
import java.lang.Exception; import java.lang.Exception;
import java.sql.Date;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
@ -17,7 +20,7 @@ public class JSONTest {
@Before @Before
public void setup() { public void setup() {
json = new JSON(); json = new ApiClient().getJSON();
order = new Order(); order = new Order();
} }
@ -42,4 +45,18 @@ public class JSONTest {
Order o = json.getContext(null).readValue(str, Order.class); Order o = json.getContext(null).readValue(str, Order.class);
assertEquals(dateStr, dateFormat.print(o.getShipDate())); assertEquals(dateStr, dateFormat.print(o.getShipDate()));
} }
@Test
public void testSqlDateSerialization() throws Exception {
String str = json.getContext(null).writeValueAsString(new java.sql.Date(10));
assertEquals("\"1970-01-01\"", str);
}
@Test
public void testSqlDateDeserialization() throws Exception {
final String str = "1970-01-01";
java.sql.Date date = json.getContext(null).readValue("\"" + str + "\"", java.sql.Date.class);
assertEquals(date.toString(), str);
}
} }

View File

@ -1,16 +1,13 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{815BE834-0656-4C12-84A4-43F2BA4B8BDE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
global.json = global.json global.json = global.json
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.xproj", "" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.xproj", "{CF700387-34B9-4172-B648-7535827D5EEB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -18,15 +15,12 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF700387-34B9-4172-B648-7535827D5EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF700387-34B9-4172-B648-7535827D5EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF700387-34B9-4172-B648-7535827D5EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.Build.0 = Release|Any CPU {CF700387-34B9-4172-B648-7535827D5EEB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
= {815BE834-0656-4C12-84A4-43F2BA4B8BDE}
EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid></ProjectGuid> <ProjectGuid>{CF700387-34B9-4172-B648-7535827D5EEB}</ProjectGuid>
<RootNamespace>Sample</RootNamespace> <RootNamespace>IO.Swagger</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,28 @@
# Swagger generated server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled Flask server.
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
To run the server, please execute the following:
```
sudo pip install -U connexion # install Connexion from PyPI
python app.py
```
and open your browser to here:
```
http://localhost:8080/v2/ui/
```
Your Swagger definition lives here:
```
http://localhost:8080/v2/swagger.json
```

View File

@ -0,0 +1,8 @@
#!/usr/bin/env python
import connexion
if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.'})
app.run(port=8080)

View File

@ -0,0 +1,24 @@
def add_pet(body):
return 'do some magic!'
def delete_pet(petId, apiKey = None):
return 'do some magic!'
def find_pets_by_status(status):
return 'do some magic!'
def find_pets_by_tags(tags):
return 'do some magic!'
def get_pet_by_id(petId):
return 'do some magic!'
def update_pet(body):
return 'do some magic!'
def update_pet_with_form(petId, name = None, status = None):
return 'do some magic!'
def upload_file(petId, additionalMetadata = None, file = None):
return 'do some magic!'

View File

@ -0,0 +1,12 @@
def delete_order(orderId):
return 'do some magic!'
def get_inventory():
return 'do some magic!'
def get_order_by_id(orderId):
return 'do some magic!'
def place_order(body):
return 'do some magic!'

View File

@ -0,0 +1,24 @@
def create_user(body):
return 'do some magic!'
def create_users_with_array_input(body):
return 'do some magic!'
def create_users_with_list_input(body):
return 'do some magic!'
def delete_user(username):
return 'do some magic!'
def get_user_by_name(username):
return 'do some magic!'
def login_user(username, password):
return 'do some magic!'
def logout_user():
return 'do some magic!'
def update_user(username, body):
return 'do some magic!'

View File

@ -0,0 +1,754 @@
---
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about\
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
\ For this sample, you can use the api key `special-key` to test the authorization\
\ filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Access to Petstore orders"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes:
- "http"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "controllers.pet_controller.add_pet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
put:
tags:
- "pet"
summary: "Update an existing pet"
description: ""
operationId: "controllers.pet_controller.update_pet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
405:
description: "Validation exception"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet/findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "controllers.pet_controller.find_pets_by_status"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
required: true
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
400:
description: "Invalid status value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet/findByTags:
get:
tags:
- "pet"
summary: "Finds Pets by tags"
description: "Multiple tags can be provided with comma separated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: "controllers.pet_controller.find_pets_by_tags"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "tags"
in: "query"
description: "Tags to filter by"
required: true
type: "array"
items:
type: "string"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
400:
description: "Invalid tag value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet/{petId}:
get:
tags:
- "pet"
summary: "Find pet by ID"
description: "Returns a single pet"
operationId: "controllers.pet_controller.get_pet_by_id"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to return"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Pet"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
x-tags:
- tag: "pet"
post:
tags:
- "pet"
summary: "Updates a pet in the store with form data"
description: ""
operationId: "controllers.pet_controller.update_pet_with_form"
consumes:
- "application/x-www-form-urlencoded"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be updated"
required: true
type: "integer"
format: "int64"
- name: "name"
in: "formData"
description: "Updated name of the pet"
required: false
type: "string"
- name: "status"
in: "formData"
description: "Updated status of the pet"
required: false
type: "string"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
delete:
tags:
- "pet"
summary: "Deletes a pet"
description: ""
operationId: "controllers.pet_controller.delete_pet"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "api_key"
in: "header"
required: false
type: "string"
- name: "petId"
in: "path"
description: "Pet id to delete"
required: true
type: "integer"
format: "int64"
responses:
400:
description: "Invalid pet value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet/{petId}/uploadImage:
post:
tags:
- "pet"
summary: "uploads an image"
description: ""
operationId: "controllers.pet_controller.upload_file"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to update"
required: true
type: "integer"
format: "int64"
- name: "additionalMetadata"
in: "formData"
description: "Additional data to pass to server"
required: false
type: "string"
- name: "file"
in: "formData"
description: "file to upload"
required: false
type: "file"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/ApiResponse"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/store/inventory:
get:
tags:
- "store"
summary: "Returns pet inventories by status"
description: "Returns a map of status codes to quantities"
operationId: "controllers.store_controller.get_inventory"
produces:
- "application/json"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "integer"
format: "int32"
security:
- api_key: []
x-tags:
- tag: "store"
/store/order:
post:
tags:
- "store"
summary: "Place an order for a pet"
description: ""
operationId: "controllers.store_controller.place_order"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "order placed for purchasing the pet"
required: true
schema:
$ref: "#/definitions/Order"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Order"
400:
description: "Invalid Order"
x-tags:
- tag: "store"
/store/order/{orderId}:
get:
tags:
- "store"
summary: "Find purchase order by ID"
description: "For valid response try integer IDs with value <= 5 or > 10. Other\
\ values will generated exceptions"
operationId: "controllers.store_controller.get_order_by_id"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
maximum: 5.0
minimum: 1.0
format: "int64"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Order"
400:
description: "Invalid ID supplied"
404:
description: "Order not found"
x-tags:
- tag: "store"
delete:
tags:
- "store"
summary: "Delete purchase order by ID"
description: "For valid response try integer IDs with value < 1000. Anything\
\ above 1000 or nonintegers will generate API errors"
operationId: "controllers.store_controller.delete_order"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of the order that needs to be deleted"
required: true
type: "string"
minimum: 1.0
responses:
400:
description: "Invalid ID supplied"
404:
description: "Order not found"
x-tags:
- tag: "store"
/user:
post:
tags:
- "user"
summary: "Create user"
description: "This can only be done by the logged in user."
operationId: "controllers.user_controller.create_user"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Created user object"
required: true
schema:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
x-tags:
- tag: "user"
/user/createWithArray:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "controllers.user_controller.create_users_with_array_input"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
schema:
type: "array"
items:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
x-tags:
- tag: "user"
/user/createWithList:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "controllers.user_controller.create_users_with_list_input"
produces:
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
schema:
type: "array"
items:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
x-tags:
- tag: "user"
/user/login:
get:
tags:
- "user"
summary: "Logs user into the system"
description: ""
operationId: "controllers.user_controller.login_user"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "query"
description: "The user name for login"
required: true
type: "string"
- name: "password"
in: "query"
description: "The password for login in clear text"
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "string"
headers:
X-Rate-Limit:
type: "integer"
format: "int32"
description: "calls per hour allowed by the user"
X-Expires-After:
type: "string"
format: "date-time"
description: "date in UTC when toekn expires"
400:
description: "Invalid username/password supplied"
x-tags:
- tag: "user"
/user/logout:
get:
tags:
- "user"
summary: "Logs out current logged in user session"
description: ""
operationId: "controllers.user_controller.logout_user"
produces:
- "application/xml"
- "application/json"
parameters: []
responses:
default:
description: "successful operation"
x-tags:
- tag: "user"
/user/{username}:
get:
tags:
- "user"
summary: "Get user by user name"
description: ""
operationId: "controllers.user_controller.get_user_by_name"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "The name that needs to be fetched. Use user1 for testing. "
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/User"
400:
description: "Invalid username supplied"
404:
description: "User not found"
x-tags:
- tag: "user"
put:
tags:
- "user"
summary: "Updated user"
description: "This can only be done by the logged in user."
operationId: "controllers.user_controller.update_user"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "name that need to be deleted"
required: true
type: "string"
- in: "body"
name: "body"
description: "Updated user object"
required: true
schema:
$ref: "#/definitions/User"
responses:
400:
description: "Invalid user supplied"
404:
description: "User not found"
x-tags:
- tag: "user"
delete:
tags:
- "user"
summary: "Delete user"
description: "This can only be done by the logged in user."
operationId: "controllers.user_controller.delete_user"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
description: "The name that needs to be deleted"
required: true
type: "string"
responses:
400:
description: "Invalid username supplied"
404:
description: "User not found"
x-tags:
- tag: "user"
securityDefinitions:
api_key:
type: "apiKey"
name: "api_key"
in: "header"
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
definitions:
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
title: "Pet Order"
description: "An order for a pets from the pet store"
xml:
name: "Order"
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
title: "Pet catehgry"
description: "A category for a pet"
xml:
name: "Category"
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
username:
type: "string"
firstName:
type: "string"
lastName:
type: "string"
email:
type: "string"
password:
type: "string"
phone:
type: "string"
userStatus:
type: "integer"
format: "int32"
description: "User Status"
title: "a User"
description: "A User who is purchasing from the pet store"
xml:
name: "User"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
title: "Pet Tag"
description: "A tag for a pet"
xml:
name: "Tag"
Pet:
type: "object"
required:
- "name"
- "photoUrls"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/definitions/Category"
name:
type: "string"
example: "doggie"
photoUrls:
type: "array"
xml:
name: "photoUrl"
wrapped: true
items:
type: "string"
tags:
type: "array"
xml:
name: "tag"
wrapped: true
items:
$ref: "#/definitions/Tag"
status:
type: "string"
description: "pet status in the store"
enum:
- "available"
- "pending"
- "sold"
title: "a Pet"
description: "A pet for sale in the pet store"
xml:
name: "Pet"
ApiResponse:
type: "object"
properties:
code:
type: "integer"
format: "int32"
type:
type: "string"
message:
type: "string"
title: "An uploaded response"
description: "Describes the result of uploading an image resource"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,60 @@
package io.swagger.api;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface PetApi {
@POST
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
Response addPet(Pet body);
@DELETE
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
@GET
@Path("/findByStatus")
@Produces({ "application/xml", "application/json" })
Response findPetsByStatus(@QueryParam("status") List<String> status);
@GET
@Path("/findByTags")
@Produces({ "application/xml", "application/json" })
Response findPetsByTags(@QueryParam("tags") List<String> tags);
@GET
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
Response getPetById(@PathParam("petId") Long petId);
@PUT
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
Response updatePet(Pet body);
@POST
@Path("/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
@Produces({ "application/xml", "application/json" })
Response updatePetWithForm(@PathParam("petId") Long petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status);
@POST
@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream,
@Multipart(value = "file" , required = false) Attachment fileDetail);
}

View File

@ -0,0 +1,29 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface PetApiService {
public Response addPet(Pet body, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);
public Response findPetsByStatus(List<String> status, SecurityContext securityContext);
public Response findPetsByTags(List<String> tags, SecurityContext securityContext);
public Response getPetById(Long petId, SecurityContext securityContext);
public Response updatePet(Pet body, SecurityContext securityContext);
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext);
public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, Attachment fileDetail, SecurityContext securityContext);
}

View File

@ -0,0 +1,38 @@
package io.swagger.api;
import java.util.Map;
import io.swagger.model.Order;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface StoreApi {
@DELETE
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Response deleteOrder(@PathParam("orderId") String orderId);
@GET
@Path("/inventory")
@Produces({ "application/json" })
Response getInventory();
@GET
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Response getOrderById(@PathParam("orderId") Long orderId);
@POST
@Path("/order")
@Produces({ "application/xml", "application/json" })
Response placeOrder(Order body);
}

View File

@ -0,0 +1,24 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.Map;
import io.swagger.model.Order;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface StoreApiService {
public Response deleteOrder(String orderId, SecurityContext securityContext);
public Response getInventory(SecurityContext securityContext);
public Response getOrderById(Long orderId, SecurityContext securityContext);
public Response placeOrder(Order body, SecurityContext securityContext);
}

View File

@ -0,0 +1,58 @@
package io.swagger.api;
import io.swagger.model.User;
import java.util.List;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface UserApi {
@POST
@Produces({ "application/xml", "application/json" })
Response createUser(User body);
@POST
@Path("/createWithArray")
@Produces({ "application/xml", "application/json" })
Response createUsersWithArrayInput(List<User> body);
@POST
@Path("/createWithList")
@Produces({ "application/xml", "application/json" })
Response createUsersWithListInput(List<User> body);
@DELETE
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response deleteUser(@PathParam("username") String username);
@GET
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response getUserByName(@PathParam("username") String username);
@GET
@Path("/login")
@Produces({ "application/xml", "application/json" })
Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password);
@GET
@Path("/logout")
@Produces({ "application/xml", "application/json" })
Response logoutUser();
@PUT
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response updateUser(@PathParam("username") String username,User body);
}

View File

@ -0,0 +1,28 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.User;
import java.util.List;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface UserApiService {
public Response createUser(User body, SecurityContext securityContext);
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext);
public Response createUsersWithListInput(List<User> body, SecurityContext securityContext);
public Response deleteUser(String username, SecurityContext securityContext);
public Response getUserByName(String username, SecurityContext securityContext);
public Response loginUser(String username, String password, SecurityContext securityContext);
public Response logoutUser(SecurityContext securityContext);
public Response updateUser(String username, User body, SecurityContext securityContext);
}

View File

@ -0,0 +1,70 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
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;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Category", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Category")
public class Category {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="name")
private String name = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Category {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
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

@ -0,0 +1,83 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
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;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ModelApiResponse", propOrder =
{ "code", "type", "message"
})
@XmlRootElement(name="ModelApiResponse")
public class ModelApiResponse {
@XmlElement(name="code")
private Integer code = null;
@XmlElement(name="type")
private String type = null;
@XmlElement(name="message")
private String message = null;
/**
**/
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
/**
**/
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
**/
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ModelApiResponse {\n");
sb.append(" code: ").append(toIndentedString(code)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" message: ").append(toIndentedString(message)).append("\n");
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

@ -0,0 +1,146 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
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;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Order", propOrder =
{ "id", "petId", "quantity", "shipDate", "status", "complete"
})
@XmlRootElement(name="Order")
public class Order {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="petId")
private Long petId = null;
@XmlElement(name="quantity")
private Integer quantity = null;
@XmlElement(name="shipDate")
private java.util.Date shipDate = null;
@XmlType(name="StatusEnum")
@XmlEnum
public enum StatusEnum {
PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered"));
private String value;
StatusEnum (String v) {
value = v;
}
public String value() {
return value;
}
public static StatusEnum fromValue(String v) {
return valueOf(v);
}
}
@XmlElement(name="status")
private StatusEnum status = null;
@XmlElement(name="complete")
private Boolean complete = false;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public Long getPetId() {
return petId;
}
public void setPetId(Long petId) {
this.petId = petId;
}
/**
**/
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
/**
**/
public java.util.Date getShipDate() {
return shipDate;
}
public void setShipDate(java.util.Date shipDate) {
this.shipDate = shipDate;
}
/**
* Order Status
**/
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
/**
**/
public Boolean getComplete() {
return complete;
}
public void setComplete(Boolean complete) {
this.complete = complete;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Order {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
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

@ -0,0 +1,150 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.model.Category;
import io.swagger.model.Tag;
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.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Pet", propOrder =
{ "id", "category", "name", "photoUrls", "tags", "status"
})
@XmlRootElement(name="Pet")
public class Pet {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="category")
private Category category = null;
@XmlElement(name="name")
private String name = null;
@XmlElement(name="photoUrls")
private List<String> photoUrls = new ArrayList<String>();
@XmlElement(name="tags")
private List<Tag> tags = new ArrayList<Tag>();
@XmlType(name="StatusEnum")
@XmlEnum
public enum StatusEnum {
AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold"));
private String value;
StatusEnum (String v) {
value = v;
}
public String value() {
return value;
}
public static StatusEnum fromValue(String v) {
return valueOf(v);
}
}
@XmlElement(name="status")
private StatusEnum status = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
/**
* pet status in the store
**/
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Pet {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
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

@ -0,0 +1,70 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
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;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Tag", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Tag")
public class Tag {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="name")
private String name = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Tag {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
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

@ -0,0 +1,149 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
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;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "User", propOrder =
{ "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"
})
@XmlRootElement(name="User")
public class User {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="username")
private String username = null;
@XmlElement(name="firstName")
private String firstName = null;
@XmlElement(name="lastName")
private String lastName = null;
@XmlElement(name="email")
private String email = null;
@XmlElement(name="password")
private String password = null;
@XmlElement(name="phone")
private String phone = null;
@XmlElement(name="userStatus")
private Integer userStatus = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
/**
**/
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
**/
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
**/
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/**
**/
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
/**
**/
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
* User Status
**/
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
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

@ -0,0 +1,64 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class PetApiServiceImpl implements PetApiService {
@Override
public Response addPet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response findPetsByStatus(List<String> status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response findPetsByTags(List<String> tags, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getPetById(Long petId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updatePet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, Attachment fileDetail, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,43 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.Map;
import io.swagger.model.Order;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class StoreApiServiceImpl implements StoreApiService {
@Override
public Response deleteOrder(String orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getInventory(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getOrderById(Long orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response placeOrder(Order body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,63 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.User;
import java.util.List;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class UserApiServiceImpl implements UserApiService {
@Override
public Response createUser(User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response createUsersWithListInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response deleteUser(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getUserByName(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response loginUser(String username, String password, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response logoutUser(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updateUser(String username, User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,831 @@
{
"swagger" : "2.0",
"info" : {
"description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version" : "1.0.0",
"title" : "Swagger Petstore",
"termsOfService" : "http://swagger.io/terms/",
"contact" : {
"email" : "apiteam@swagger.io"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host" : "petstore.swagger.io",
"basePath" : "/v2",
"tags" : [ {
"name" : "pet",
"description" : "Everything about your Pets",
"externalDocs" : {
"description" : "Find out more",
"url" : "http://swagger.io"
}
}, {
"name" : "store",
"description" : "Access to Petstore orders"
}, {
"name" : "user",
"description" : "Operations about user",
"externalDocs" : {
"description" : "Find out more about our store",
"url" : "http://swagger.io"
}
} ],
"schemes" : [ "http" ],
"paths" : {
"/pet" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "Add a new pet to the store",
"description" : "",
"operationId" : "addPet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"put" : {
"tags" : [ "pet" ],
"summary" : "Update an existing pet",
"description" : "",
"operationId" : "updatePet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Pet not found"
},
"405" : {
"description" : "Validation exception"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByStatus" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by status",
"description" : "Multiple status values can be provided with comma separated strings",
"operationId" : "findPetsByStatus",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : true,
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByTags" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by tags",
"description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
"operationId" : "findPetsByTags",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : true,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid tag value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Find pet by ID",
"description" : "Returns a single pet",
"operationId" : "getPetById",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to return",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Pet"
}
},
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Pet not found"
}
},
"security" : [ {
"api_key" : [ ]
} ]
},
"post" : {
"tags" : [ "pet" ],
"summary" : "Updates a pet in the store with form data",
"description" : "",
"operationId" : "updatePetWithForm",
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
}, {
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"type" : "string"
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"delete" : {
"tags" : [ "pet" ],
"summary" : "Deletes a pet",
"description" : "",
"operationId" : "deletePet",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"required" : false,
"type" : "string"
}, {
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"400" : {
"description" : "Invalid pet value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}/uploadImage" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "uploads an image",
"description" : "",
"operationId" : "uploadFile",
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to update",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "additionalMetadata",
"in" : "formData",
"description" : "Additional data to pass to server",
"required" : false,
"type" : "string"
}, {
"name" : "file",
"in" : "formData",
"description" : "file to upload",
"required" : false,
"type" : "file"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/ApiResponse"
}
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/store/inventory" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Returns pet inventories by status",
"description" : "Returns a map of status codes to quantities",
"operationId" : "getInventory",
"produces" : [ "application/json" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"security" : [ {
"api_key" : [ ]
} ]
}
},
"/store/order" : {
"post" : {
"tags" : [ "store" ],
"summary" : "Place an order for a pet",
"description" : "",
"operationId" : "placeOrder",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Order"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid Order"
}
}
}
},
"/store/order/{orderId}" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Find purchase order by ID",
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"operationId" : "getOrderById",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"maximum" : 5.0,
"minimum" : 1.0,
"format" : "int64"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Order not found"
}
}
},
"delete" : {
"tags" : [ "store" ],
"summary" : "Delete purchase order by ID",
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"operationId" : "deleteOrder",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string",
"minimum" : 1.0
} ],
"responses" : {
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Order not found"
}
}
}
},
"/user" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Create user",
"description" : "This can only be done by the logged in user.",
"operationId" : "createUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : true,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithArray" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithArrayInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithList" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithListInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/login" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs user into the system",
"description" : "",
"operationId" : "loginUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : true,
"type" : "string"
}, {
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "string"
},
"headers" : {
"X-Rate-Limit" : {
"type" : "integer",
"format" : "int32",
"description" : "calls per hour allowed by the user"
},
"X-Expires-After" : {
"type" : "string",
"format" : "date-time",
"description" : "date in UTC when toekn expires"
}
}
},
"400" : {
"description" : "Invalid username/password supplied"
}
}
}
},
"/user/logout" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs out current logged in user session",
"description" : "",
"operationId" : "logoutUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/{username}" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Get user by user name",
"description" : "",
"operationId" : "getUserByName",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/User"
}
},
"400" : {
"description" : "Invalid username supplied"
},
"404" : {
"description" : "User not found"
}
}
},
"put" : {
"tags" : [ "user" ],
"summary" : "Updated user",
"description" : "This can only be done by the logged in user.",
"operationId" : "updateUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "name that need to be deleted",
"required" : true,
"type" : "string"
}, {
"in" : "body",
"name" : "body",
"description" : "Updated user object",
"required" : true,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"400" : {
"description" : "Invalid user supplied"
},
"404" : {
"description" : "User not found"
}
}
},
"delete" : {
"tags" : [ "user" ],
"summary" : "Delete user",
"description" : "This can only be done by the logged in user.",
"operationId" : "deleteUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"400" : {
"description" : "Invalid username supplied"
},
"404" : {
"description" : "User not found"
}
}
}
}
},
"securityDefinitions" : {
"petstore_auth" : {
"type" : "oauth2",
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
"flow" : "implicit",
"scopes" : {
"write:pets" : "modify pets in your account",
"read:pets" : "read your pets"
}
},
"api_key" : {
"type" : "apiKey",
"name" : "api_key",
"in" : "header"
}
},
"definitions" : {
"Order" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"petId" : {
"type" : "integer",
"format" : "int64"
},
"quantity" : {
"type" : "integer",
"format" : "int32"
},
"shipDate" : {
"type" : "string",
"format" : "date-time"
},
"status" : {
"type" : "string",
"description" : "Order Status",
"enum" : [ "placed", "approved", "delivered" ]
},
"complete" : {
"type" : "boolean",
"default" : false
}
},
"title" : "Pet Order",
"description" : "An order for a pets from the pet store",
"xml" : {
"name" : "Order"
}
},
"Category" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet catehgry",
"description" : "A category for a pet",
"xml" : {
"name" : "Category"
}
},
"User" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"username" : {
"type" : "string"
},
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"email" : {
"type" : "string"
},
"password" : {
"type" : "string"
},
"phone" : {
"type" : "string"
},
"userStatus" : {
"type" : "integer",
"format" : "int32",
"description" : "User Status"
}
},
"title" : "a User",
"description" : "A User who is purchasing from the pet store",
"xml" : {
"name" : "User"
}
},
"Tag" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet Tag",
"description" : "A tag for a pet",
"xml" : {
"name" : "Tag"
}
},
"Pet" : {
"type" : "object",
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"category" : {
"$ref" : "#/definitions/Category"
},
"name" : {
"type" : "string",
"example" : "doggie"
},
"photoUrls" : {
"type" : "array",
"xml" : {
"name" : "photoUrl",
"wrapped" : true
},
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
"xml" : {
"name" : "tag",
"wrapped" : true
},
"items" : {
"$ref" : "#/definitions/Tag"
}
},
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum" : [ "available", "pending", "sold" ]
}
},
"title" : "a Pet",
"description" : "A pet for sale in the pet store",
"xml" : {
"name" : "Pet"
}
},
"ApiResponse" : {
"type" : "object",
"properties" : {
"code" : {
"type" : "integer",
"format" : "int32"
},
"type" : {
"type" : "string"
},
"message" : {
"type" : "string"
}
},
"title" : "An uploaded response",
"description" : "Describes the result of uploading an image resource"
}
},
"externalDocs" : {
"description" : "Find out more about Swagger",
"url" : "http://swagger.io"
}
}

View File

@ -0,0 +1,47 @@
package io.swagger.api;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.format.ISODateTimeFormat;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
@Provider
public class JacksonConfig implements ContextResolver<ObjectMapper> {
private final ObjectMapper objectMapper;
public JacksonConfig() throws Exception {
objectMapper = new ObjectMapper()
.setDateFormat(new RFC3339DateFormat())
.registerModule(new JodaModule() {
{
addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) {
@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().print(value));
}
});
addSerializer(LocalDate.class, new StdSerializer<LocalDate>(LocalDate.class) {
@Override
public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
jgen.writeString(ISODateTimeFormat.date().print(value));
}
});
}
});
}
public ObjectMapper getContext(Class<?> arg0) {
return objectMapper;
}
}

View File

@ -0,0 +1,19 @@
package io.swagger.api;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -20,24 +20,25 @@ public class JacksonConfig implements ContextResolver<ObjectMapper> {
public JacksonConfig() throws Exception { public JacksonConfig() throws Exception {
objectMapper = new ObjectMapper(); objectMapper = new ObjectMapper()
objectMapper.registerModule(new JodaModule() { .setDateFormat(new RFC3339DateFormat())
{ .registerModule(new JodaModule() {
addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) { {
@Override addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) {
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { @Override
jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().print(value)); public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
} jgen.writeString(ISODateTimeFormat.dateTimeNoMillis().print(value));
}); }
addSerializer(LocalDate.class, new StdSerializer<LocalDate>(LocalDate.class) { });
@Override addSerializer(LocalDate.class, new StdSerializer<LocalDate>(LocalDate.class) {
public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { @Override
jgen.writeString(ISODateTimeFormat.date().print(value)); public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
} jgen.writeString(ISODateTimeFormat.date().print(value));
}); }
});
} }
}); });
} }
public ObjectMapper getContext(Class<?> arg0) { public ObjectMapper getContext(Class<?> arg0) {

View File

@ -0,0 +1,19 @@
package io.swagger.api;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
public class User { public class User {
private Long id = null; private Long id = null;

View File

@ -10,8 +10,8 @@ import io.swagger.jaxrs.*;
import com.sun.jersey.multipart.FormDataParam; import com.sun.jersey.multipart.FormDataParam;
import io.swagger.model.Client; import io.swagger.model.Client;
import java.util.Date;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;

View File

@ -6,8 +6,8 @@ import io.swagger.model.*;
import com.sun.jersey.multipart.FormDataParam; import com.sun.jersey.multipart.FormDataParam;
import io.swagger.model.Client; import io.swagger.model.Client;
import java.util.Date;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;

View File

@ -1,8 +1,10 @@
package io.swagger.api; package io.swagger.api;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import io.swagger.util.Json;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -11,9 +13,15 @@ import javax.ws.rs.ext.Provider;
@Provider @Provider
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public class JacksonJsonProvider extends JacksonJaxbJsonProvider { public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
private static ObjectMapper commonMapper = Json.mapper();
public JacksonJsonProvider() { public JacksonJsonProvider() {
super.setMapper(commonMapper);
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.registerModule(new JodaModule())
.setDateFormat(new RFC3339DateFormat());
setMapper(objectMapper);
} }
} }

View File

@ -10,8 +10,8 @@ import io.swagger.jaxrs.*;
import com.sun.jersey.multipart.FormDataParam; import com.sun.jersey.multipart.FormDataParam;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse; import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;

Some files were not shown because too many files have changed in this diff Show More