forked from loafle/openapi-generator-original
Merge branch 'TobiasPfeifer-develop_2.0' into develop_2.0
This commit is contained in:
commit
718e1ff68a
@ -102,21 +102,6 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeDeclaration(Property p) {
|
|
||||||
if (p instanceof ArrayProperty) {
|
|
||||||
ArrayProperty ap = (ArrayProperty) p;
|
|
||||||
Property inner = ap.getItems();
|
|
||||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
|
||||||
} else if (p instanceof MapProperty) {
|
|
||||||
MapProperty mp = (MapProperty) p;
|
|
||||||
Property inner = mp.getAdditionalProperties();
|
|
||||||
|
|
||||||
return getTypeDeclaration(inner);
|
|
||||||
}
|
|
||||||
return super.getTypeDeclaration(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||||
String basePath = resourcePath;
|
String basePath = resourcePath;
|
||||||
@ -158,27 +143,30 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println(operation.operationId);
|
||||||
|
io.swagger.util.Json.prettyPrint(operation);
|
||||||
|
|
||||||
if (operation.returnType == null) {
|
if (operation.returnType == null) {
|
||||||
operation.returnType = "Void";
|
operation.returnType = "Void";
|
||||||
} else if (operation.returnType.startsWith("List")) {
|
} else if (operation.returnType.startsWith("List")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("List<".length(), end);
|
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||||
operation.returnContainer = "List";
|
operation.returnContainer = "List";
|
||||||
}
|
}
|
||||||
} else if (operation.returnType.startsWith("Map")) {
|
} else if (operation.returnType.startsWith("Map")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("Map<".length(), end);
|
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||||
operation.returnContainer = "Map";
|
operation.returnContainer = "Map";
|
||||||
}
|
}
|
||||||
} else if (operation.returnType.startsWith("Set")) {
|
} else if (operation.returnType.startsWith("Set")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("Set<".length(), end);
|
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||||
operation.returnContainer = "Set";
|
operation.returnContainer = "Set";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,11 @@ public class {{classname}} {
|
|||||||
{{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
|
{{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}
|
||||||
{{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
|
{{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}
|
||||||
method = RequestMethod.{{httpMethod}})
|
method = RequestMethod.{{httpMethod}})
|
||||||
public ResponseEntity<{{returnType}}> {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
public ResponseEntity<{{>returnTypes}}> {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||||
{{/hasMore}}{{/allParams}})
|
{{/hasMore}}{{/allParams}})
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return new ResponseEntity<{{returnType}}>(HttpStatus.OK);
|
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -150,7 +150,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.0</swagger-core-version>
|
<swagger-core-version>1.5.3</swagger-core-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<jersey-version>1.13</jersey-version>
|
<jersey-version>1.13</jersey-version>
|
||||||
<slf4j-version>1.6.3</slf4j-version>
|
<slf4j-version>1.6.3</slf4j-version>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{{#returnContainer}}{{#isMapContainer}}Map<String, {{{returnType}}}>{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
@ -150,7 +150,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.0</swagger-core-version>
|
<swagger-core-version>1.5.3</swagger-core-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<jersey-version>1.13</jersey-version>
|
<jersey-version>1.13</jersey-version>
|
||||||
<slf4j-version>1.6.3</slf4j-version>
|
<slf4j-version>1.6.3</slf4j-version>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.api;
|
package io.swagger.api;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception{
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
public ApiException (int code, String msg) {
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.api;
|
|||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
@javax.xml.bind.annotation.XmlRootElement
|
@javax.xml.bind.annotation.XmlRootElement
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class ApiResponseMessage {
|
public class ApiResponseMessage {
|
||||||
public static final int ERROR = 1;
|
public static final int ERROR = 1;
|
||||||
public static final int WARNING = 2;
|
public static final int WARNING = 2;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.api;
|
package io.swagger.api;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class NotFoundException extends ApiException {
|
public class NotFoundException extends ApiException {
|
||||||
private int code;
|
private int code;
|
||||||
public NotFoundException (int code, String msg) {
|
public NotFoundException (int code, String msg) {
|
||||||
|
@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*;
|
|||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
|
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
|
||||||
@Api(value = "/pet", description = "the pet API")
|
@Api(value = "/pet", description = "the pet API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
|
|
||||||
|
|
||||||
@ -77,12 +78,12 @@ public class PetApi {
|
|||||||
produces = { "application/json", "application/xml" },
|
produces = { "application/json", "application/xml" },
|
||||||
|
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
public ResponseEntity<Pet> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List<String> status
|
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List<String> status
|
||||||
|
|
||||||
)
|
)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,12 +96,12 @@ public class PetApi {
|
|||||||
produces = { "application/json", "application/xml" },
|
produces = { "application/json", "application/xml" },
|
||||||
|
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
public ResponseEntity<Pet> findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List<String> tags
|
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List<String> tags
|
||||||
|
|
||||||
)
|
)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -157,10 +158,10 @@ public class PetApi {
|
|||||||
|
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
public ResponseEntity<Void> deletePet(
|
public ResponseEntity<Void> deletePet(
|
||||||
@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey
|
@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
|
||||||
,
|
,
|
||||||
|
|
||||||
@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
|
@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey
|
||||||
)
|
)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
|
@ -30,20 +30,21 @@ import static org.springframework.http.MediaType.*;
|
|||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
|
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
|
||||||
@Api(value = "/store", description = "the store API")
|
@Api(value = "/store", description = "the store API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
|
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/inventory",
|
@RequestMapping(value = "/inventory",
|
||||||
produces = { "application/json", "application/xml" },
|
produces = { "application/json", "application/xml" },
|
||||||
|
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
public ResponseEntity<Integer> getInventory()
|
public ResponseEntity<Map<String, Integer>> getInventory()
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return new ResponseEntity<Integer>(HttpStatus.OK);
|
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*;
|
|||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
|
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
|
||||||
@Api(value = "/user", description = "the user API")
|
@Api(value = "/user", description = "the user API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
@EnableSwagger2 //Loads the spring beans required by the framework
|
||||||
@PropertySource("classpath:swagger.properties")
|
@PropertySource("classpath:swagger.properties")
|
||||||
@Import(SwaggerUiConfiguration.class)
|
@Import(SwaggerUiConfiguration.class)
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@Bean
|
@Bean
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
|
@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package io.swagger.configuration;
|
|||||||
|
|
||||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.configuration;
|
|||||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
@Override
|
@Override
|
||||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package io.swagger.model;
|
package io.swagger.model;
|
||||||
|
|
||||||
import io.swagger.model.Category;
|
import io.swagger.model.Category;
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.model.Tag;
|
import io.swagger.model.Tag;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
private Category category = null;
|
private Category category = null;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private List<String> photoUrls = new ArrayList<String>() ;
|
private List<String> photoUrls = new ArrayList<String>();
|
||||||
private List<Tag> tags = new ArrayList<Tag>() ;
|
private List<Tag> tags = new ArrayList<Tag>();
|
||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
available, pending, sold,
|
available, pending, sold,
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class Tag {
|
public class Tag {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user