mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
added consumes, produces
This commit is contained in:
parent
949b321e13
commit
bad6798433
@ -5,7 +5,7 @@ import com.wordnik.swagger.models.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenOperation {
|
||||
public Boolean hasParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation;
|
||||
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
|
||||
|
@ -562,6 +562,7 @@ public class DefaultCodegen {
|
||||
c.add(mediaType);
|
||||
}
|
||||
op.consumes = c;
|
||||
op.hasConsumes = true;
|
||||
}
|
||||
|
||||
if(operation.getProduces() != null && operation.getProduces().size() > 0) {
|
||||
@ -576,6 +577,7 @@ public class DefaultCodegen {
|
||||
c.add(mediaType);
|
||||
}
|
||||
op.produces = c;
|
||||
op.hasProduces = true;
|
||||
}
|
||||
|
||||
if(operation.getResponses() != null) {
|
||||
|
@ -3,6 +3,7 @@ package {{package}};
|
||||
import {{modelPackage}}.*;
|
||||
|
||||
import com.wordnik.swagger.annotations.*;
|
||||
import com.sun.jersey.multipart.FormDataParam;
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
@ -15,18 +16,19 @@ import javax.ws.rs.*;
|
||||
|
||||
@Path("/{{baseName}}")
|
||||
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||
@Produces({"application/json"})
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
{{#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}})
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
|
||||
{{/hasMore}}{{/responses}} })
|
||||
|
||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{#hasMore}},
|
||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}})
|
||||
throws NotFoundException {
|
||||
// do some magic!
|
||||
|
@ -71,9 +71,8 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<artifactId>swagger-jaxrs</artifactId>
|
||||
<artifactId>swagger-jersey-jaxrs</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -95,6 +94,16 @@
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-multipart</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user