forked from loafle/openapi-generator-original
minor fix to spring use of examples
This commit is contained in:
parent
3ca77d3cf2
commit
a17e80dfb1
@ -50,7 +50,7 @@ public interface {{classname}} {
|
||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||
method = RequestMethod.{{httpMethod}})
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}throws IOException{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
// do some magic!
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
||||
}{{/jdk8}}
|
||||
|
@ -38,27 +38,45 @@ public class {{classname}}Controller implements {{classname}} {
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public {{classname}}Controller({{classname}}Delegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}{{/isDelegate}}
|
||||
}
|
||||
|
||||
{{^jdk8-no-delegate}}{{#operation}}
|
||||
{{/isDelegate}}
|
||||
{{^jdk8-no-delegate}}
|
||||
{{#operation}}
|
||||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}) {{#examples}}throws IOException{{/examples}} {
|
||||
// do some magic!{{^isDelegate}}{{^async}}
|
||||
|
||||
{{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} {
|
||||
// do some magic!
|
||||
{{^isDelegate}}
|
||||
{{^async}}
|
||||
{{#examples}}
|
||||
{{#-first}}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue({{{example}}},{{>exampleReturnTypes}}.class), HttpStatus.OK);
|
||||
|
||||
{{/-first}}
|
||||
if ("{{{contentType}}}".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{{example}}}",{{>exampleReturnTypes}}.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
{{/examples}}
|
||||
{{^examples}}
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/examples}}{{/async}}{{#async}}
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
{{/examples}}
|
||||
{{/async}}
|
||||
{{#async}}
|
||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
||||
@Override
|
||||
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
}
|
||||
};{{/async}}{{/isDelegate}}{{#isDelegate}}
|
||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/isDelegate}}
|
||||
};
|
||||
{{/async}}
|
||||
{{/isDelegate}}
|
||||
{{#isDelegate}}
|
||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/isDelegate}}
|
||||
}
|
||||
{{/operation}}{{/jdk8-no-delegate}}
|
||||
{{/operation}}
|
||||
{{/jdk8-no-delegate}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@ -31,7 +32,7 @@ public interface FakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = {
|
||||
|
@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,14 +26,18 @@ import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{
|
||||
"client" : "aeiou"
|
||||
}",Client.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,
|
||||
@ -49,7 +55,6 @@ public class FakeApiController implements FakeApi {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List<String> enumFormStringArray,
|
||||
@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,
|
||||
@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List<String> enumHeaderStringArray,
|
||||
@ -61,5 +66,4 @@ public class FakeApiController implements FakeApi {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@ -66,7 +67,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status);
|
||||
ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -82,7 +83,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -96,7 +97,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId);
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
|
||||
@ -146,6 +147,6 @@ public interface PetApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "multipart/form-data" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file);
|
||||
ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -23,52 +25,147 @@ import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status) {
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>",List.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ]",List.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) {
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>",List.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ]",List.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>",Pet.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}",Pet.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,
|
||||
@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
|
||||
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) {
|
||||
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{
|
||||
"code" : 0,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
}",ModelApiResponse.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@ -41,7 +42,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
ResponseEntity<Map<String, Integer>> getInventory() throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -53,7 +54,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId);
|
||||
ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -64,6 +65,6 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -22,27 +24,76 @@ import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) {
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{
|
||||
"key" : 0
|
||||
}",Map.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Order>(objectMapper.readValue("<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>",Order.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Order>(objectMapper.readValue("{
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}",Order.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Order>(objectMapper.readValue("<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>",Order.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<Order>(objectMapper.readValue("{
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}",Order.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.*;
|
||||
@ -71,7 +72,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username);
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", })
|
||||
@ -82,7 +83,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/login",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<String> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
ResponseEntity<String> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException;
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
|
||||
|
@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -22,49 +24,76 @@ import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) {
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<User>(objectMapper.readValue("<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>",User.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{
|
||||
"firstName" : "aeiou",
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 6,
|
||||
"phone" : "aeiou",
|
||||
"id" : 0,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}",User.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<String> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) {
|
||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou",String.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept"
|
||||
return new ResponseEntity<String>(objectMapper.readValue(""aeiou"",String.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
public ResponseEntity<Void> logoutUser() {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
|
||||
@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user