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