mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Remove Accept request header from api signature (#6704)
* Remove Accept request header from api signature * Inject HttpServletRequest to get request header and clean templates * Use constructor injection for HttpServletRequest * Implement example in default controller responses
This commit is contained in:
parent
f14e07280a
commit
fe2ed67f20
@ -246,8 +246,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
|
||||
this.setSingleContentTypes(true);
|
||||
}
|
||||
additionalProperties.put("useSpringCloudClient", true);
|
||||
|
||||
} else {
|
||||
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
|
@ -7,12 +7,19 @@ package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{#jdk8-no-delegate}}
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
{{/jdk8-no-delegate}}
|
||||
import io.swagger.annotations.*;
|
||||
{{#jdk8}}
|
||||
{{#jdk8-no-delegate}}
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
{{/jdk8}}
|
||||
{{/jdk8-no-delegate}}
|
||||
import org.springframework.http.ResponseEntity;
|
||||
{{#useBeanValidation}}
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
{{/useBeanValidation}}
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,26 +28,54 @@ 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;
|
||||
{{^useSpringCloudClient}}
|
||||
import java.io.IOException;
|
||||
{{/useSpringCloudClient}}
|
||||
|
||||
{{#jdk8-no-delegate}}
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
{{/jdk8-no-delegate}}
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
{{/useBeanValidation}}
|
||||
{{#jdk8-no-delegate}}
|
||||
import java.io.IOException;
|
||||
{{/jdk8-no-delegate}}
|
||||
import java.util.List;
|
||||
{{#jdk8-no-delegate}}
|
||||
import java.util.Optional;
|
||||
{{/jdk8-no-delegate}}
|
||||
{{^jdk8-no-delegate}}
|
||||
{{#useOptional}}
|
||||
import java.util.Optional;
|
||||
{{/useOptional}}
|
||||
{{/jdk8-no-delegate}}
|
||||
{{#async}}
|
||||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
||||
{{/async}}
|
||||
{{#useBeanValidation}}
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
{{/useBeanValidation}}
|
||||
{{>generatedAnnotation}}
|
||||
@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API")
|
||||
{{#operations}}
|
||||
public interface {{classname}} {
|
||||
{{#jdk8}}
|
||||
|
||||
{{^isDelegate}}
|
||||
Logger log = LoggerFactory.getLogger({{classname}}.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
{{/isDelegate}}
|
||||
{{#isDelegate}}
|
||||
{{classname}}Delegate getDelegate();
|
||||
{{/isDelegate}}
|
||||
{{/jdk8}}
|
||||
{{#operation}}
|
||||
|
||||
@ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
|
||||
@ -65,20 +100,29 @@ public interface {{classname}} {
|
||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||
method = RequestMethod.{{httpMethod}})
|
||||
{{#useSpringCloudClient}}
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
// do some magic!
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}};
|
||||
{{^isDelegate}}
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
{{#examples}}
|
||||
if (getAcceptHeader().get().contains("{{{contentType}}}")) {
|
||||
try {
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}};
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type {{{contentType}}}", e);
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}};
|
||||
}
|
||||
}
|
||||
{{/examples}}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated");
|
||||
}
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}};
|
||||
{{/isDelegate}}
|
||||
{{#isDelegate}}
|
||||
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/isDelegate}}
|
||||
}{{/jdk8}}
|
||||
|
||||
{{/useSpringCloudClient}}
|
||||
{{^useSpringCloudClient}}
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader(value = "Accept", required = false) String accept) throws Exception{{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
// do some magic!
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
||||
}{{/jdk8}}
|
||||
|
||||
{{/useSpringCloudClient}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -1,16 +1,21 @@
|
||||
package {{package}};
|
||||
|
||||
{{^jdk8-no-delegate}}
|
||||
{{^jdk8}}
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{/jdk8}}
|
||||
{{^isDelegate}}
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
{{/isDelegate}}
|
||||
{{^jdk8}}
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
{{/jdk8-no-delegate}}
|
||||
{{/jdk8}}
|
||||
import org.springframework.stereotype.Controller;
|
||||
{{^jdk8-no-delegate}}
|
||||
{{^jdk8}}
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,31 +23,35 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
{{#useOptional}}
|
||||
import java.util.Optional;
|
||||
{{/useOptional}}
|
||||
{{#async}}
|
||||
import java.util.concurrent.Callable;
|
||||
{{/async}}
|
||||
{{/jdk8-no-delegate}}
|
||||
{{^useSpringCloudClient}}
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
{{/useSpringCloudClient}}
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
{{/useBeanValidation}}
|
||||
{{/jdk8}}
|
||||
{{^isDelegate}}
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
{{#jdk8}}
|
||||
import java.util.Optional;
|
||||
{{/jdk8}}
|
||||
{{/isDelegate}}
|
||||
{{^jdk8-no-delegate}}
|
||||
{{#useOptional}}
|
||||
import java.util.Optional;
|
||||
{{/useOptional}}
|
||||
{{/jdk8-no-delegate}}
|
||||
{{^jdk8}}
|
||||
{{^isDelegate}}
|
||||
import java.io.IOException;
|
||||
{{/isDelegate}}
|
||||
import java.util.List;
|
||||
{{#async}}
|
||||
import java.util.concurrent.Callable;
|
||||
{{/async}}
|
||||
{{/jdk8}}
|
||||
{{>generatedAnnotation}}
|
||||
@Controller
|
||||
{{#operations}}
|
||||
public class {{classname}}Controller implements {{classname}} {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public {{classname}}Controller(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
{{#isDelegate}}
|
||||
private final {{classname}}Delegate delegate;
|
||||
@ -51,48 +60,78 @@ public class {{classname}}Controller implements {{classname}} {
|
||||
public {{classname}}Controller({{classname}}Delegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
{{#jdk8}}
|
||||
|
||||
{{/isDelegate}}
|
||||
{{^jdk8-no-delegate}}
|
||||
{{#operation}}
|
||||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
|
||||
{{/allParams}}@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
{{#useSpringCloudClient}}
|
||||
{{^isDelegate}}
|
||||
{{^async}}
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
{{/async}}
|
||||
{{#async}}
|
||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
||||
@Override
|
||||
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
public {{classname}}Delegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
};
|
||||
{{/async}}
|
||||
{{/jdk8}}
|
||||
{{/isDelegate}}
|
||||
{{#isDelegate}}
|
||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{^isDelegate}}
|
||||
{{^jdk8}}
|
||||
private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class);
|
||||
|
||||
{{/jdk8}}
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
{{#jdk8}}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
{{/jdk8}}
|
||||
|
||||
{{/isDelegate}}
|
||||
{{/useSpringCloudClient}}
|
||||
{{^useSpringCloudClient}}
|
||||
{{^jdk8}}
|
||||
{{#operation}}
|
||||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
||||
{{^isDelegate}}
|
||||
{{^async}}
|
||||
String accept = request.getHeader("Accept");
|
||||
{{#examples}}
|
||||
|
||||
if (accept != null && accept.contains("{{{contentType}}}")) {
|
||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type {{{contentType}}}", e);
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
{{/examples}}
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED);
|
||||
{{/async}}
|
||||
{{#async}}
|
||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
||||
@Override
|
||||
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||
public ResponseEntity<{{>returnTypes}}> call() {
|
||||
String accept = request.getHeader("Accept");
|
||||
{{#examples}}
|
||||
if (accept != null && accept.contains("{{{contentType}}}")) {
|
||||
try {
|
||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type {{{contentType}}}", e);
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
{{/examples}}
|
||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
};
|
||||
{{/async}}
|
||||
@ -100,10 +139,9 @@ public class {{classname}}Controller implements {{classname}} {
|
||||
{{#isDelegate}}
|
||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/isDelegate}}
|
||||
{{/useSpringCloudClient}}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/jdk8-no-delegate}}
|
||||
{{/jdk8}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -2,13 +2,33 @@ package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import io.swagger.annotations.*;{{#jdk8}}
|
||||
import org.springframework.http.HttpStatus;{{/jdk8}}
|
||||
{{#jdk8}}
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
{{/jdk8}}
|
||||
import io.swagger.annotations.*;
|
||||
{{#jdk8}}
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
{{/jdk8}}
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
{{#jdk8}}
|
||||
import java.io.IOException;
|
||||
{{/jdk8}}
|
||||
|
||||
{{#jdk8}}
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
{{/jdk8}}
|
||||
import java.util.List;
|
||||
{{#jdk8}}
|
||||
import java.util.Optional;
|
||||
{{/jdk8}}
|
||||
{{^jdk8}}
|
||||
{{#useOptional}}
|
||||
import java.util.Optional;
|
||||
{{/useOptional}}
|
||||
{{/jdk8}}
|
||||
{{#async}}
|
||||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
||||
{{/async}}
|
||||
@ -16,11 +36,26 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
|
||||
{{#operations}}
|
||||
/**
|
||||
* A delegate to be called by the {@link {{classname}}Controller}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link {{classname}}Controller}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public interface {{classname}}Delegate {
|
||||
{{#jdk8}}
|
||||
|
||||
Logger log = LoggerFactory.getLogger({{classname}}.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
{{/jdk8}}
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
@ -28,8 +63,21 @@ public interface {{classname}}Delegate {
|
||||
*/
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
// do some magic!
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
{{#examples}}
|
||||
if (getAcceptHeader().get().contains("{{{contentType}}}")) {
|
||||
try {
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}};
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type {{{contentType}}}", e);
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}};
|
||||
}
|
||||
}
|
||||
{{/examples}}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated");
|
||||
}
|
||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}};
|
||||
}{{/jdk8}}
|
||||
|
||||
{{/operation}}
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -20,10 +20,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "Pet", description = "the Pet API")
|
||||
public interface PetApi {
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,10 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "Store", description = "the Store API")
|
||||
public interface StoreApi {
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,10 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "User", description = "the User API")
|
||||
public interface UserApi {
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,12 +19,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@ -41,7 +39,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||
@ -56,7 +54,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.DELETE)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -72,7 +70,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "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") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -88,7 +86,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -102,7 +100,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||
@ -119,7 +117,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||
@ -134,7 +132,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/x-www-form-urlencoded",
|
||||
method = RequestMethod.POST)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ -149,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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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") @Valid @RequestPart("file") MultipartFile file);
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@ -36,7 +34,7 @@ public interface StoreApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@ -48,7 +46,7 @@ public interface StoreApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -60,7 +58,7 @@ public interface StoreApi {
|
||||
produces = "application/json",
|
||||
consumes = "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("orderId") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -71,6 +69,6 @@ public interface StoreApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@ -35,7 +33,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||
@ -45,7 +43,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||
@ -55,7 +53,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -66,7 +64,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||
@ -78,7 +76,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||
@ -89,7 +87,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||
@ -99,7 +97,7 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
|
||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -110,6 +108,6 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.PUT)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,13 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,17 +21,32 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AnotherFakeApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||
@ -36,9 +54,20 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default CompletableFuture<ResponseEntity<Client>> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Client>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Client>> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,13 @@ import io.swagger.model.Client;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -22,25 +25,51 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(FakeApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Boolean>> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Boolean>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Boolean>> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -49,9 +78,20 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<OuterComposite>> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<OuterComposite>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<OuterComposite>> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -60,9 +100,20 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<BigDecimal>> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<BigDecimal>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<BigDecimal>> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -71,9 +122,20 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<String>> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<String>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<String>> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -84,9 +146,20 @@ public interface FakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default CompletableFuture<ResponseEntity<Client>> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Client>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Client>> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -100,9 +173,12 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -114,9 +190,12 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -126,9 +205,12 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Void>> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -138,9 +220,12 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<Void>> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,13 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,17 +21,32 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "", response = Client.class, authorizations = {
|
||||
@Authorization(value = "api_key_query")
|
||||
}, tags={ "fake_classname_tags 123#$%^", })
|
||||
@ -38,9 +56,20 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default CompletableFuture<ResponseEntity<Client>> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Client>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Client>> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,13 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -20,17 +23,32 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(PetApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@ -43,9 +61,12 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -60,9 +81,12 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default CompletableFuture<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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<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) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -78,9 +102,28 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<List<Pet>>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", List.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -96,9 +139,28 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<List<Pet>>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", List.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +174,28 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Pet>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", Pet.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -132,9 +213,12 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
default CompletableFuture<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -150,9 +234,12 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<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) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -168,9 +255,20 @@ public interface PetApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "multipart/form-data" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<ModelApiResponse>(HttpStatus.OK));
|
||||
default CompletableFuture<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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,10 +7,13 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,17 +22,32 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(StoreApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Delete purchase order by ID", nickname = "deleteOrder", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ -37,9 +55,12 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default CompletableFuture<ResponseEntity<Void>> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -51,9 +72,20 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<Map<String, Integer>>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Map<String, Integer>>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Map<String, Integer>>> getInventory() {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -65,9 +97,28 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<Order>> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Order>(HttpStatus.OK));
|
||||
default CompletableFuture<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(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -78,9 +129,28 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Order>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,10 +7,13 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,26 +22,44 @@ 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 java.util.concurrent.CompletableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(UserApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -48,9 +69,12 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -60,9 +84,12 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -73,9 +100,12 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default CompletableFuture<ResponseEntity<Void>> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -87,9 +117,28 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<User>> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<User>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<User>> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -100,9 +149,28 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/login",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<String>> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<String>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<String>> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED));
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +180,12 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default CompletableFuture<ResponseEntity<Void>> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<ResponseEntity<Void>> logoutUser() {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
|
||||
@ -125,9 +196,12 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
default CompletableFuture<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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Void>(HttpStatus.OK));
|
||||
default CompletableFuture<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) {
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.ofNullable(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
@ -34,6 +32,6 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,12 +21,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@ -36,7 +34,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||
@ -44,7 +42,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
|
||||
@ -52,7 +50,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
|
||||
@ -60,7 +58,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
|
||||
@ -70,7 +68,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = {
|
||||
@ -83,7 +81,7 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||
@ -94,7 +92,7 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble);
|
||||
|
||||
|
||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||
@ -103,7 +101,7 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param);
|
||||
|
||||
|
||||
@ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", })
|
||||
@ -112,6 +110,6 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2);
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -18,118 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
@ -36,6 +34,6 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,12 +19,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@ -41,7 +39,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||
@ -55,7 +53,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -70,7 +68,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") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -85,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) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -98,7 +96,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||
@ -115,7 +113,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||
@ -130,7 +128,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ -145,6 +143,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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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") @Valid @RequestPart("file") MultipartFile file);
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -16,106 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PetApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
return new ResponseEntity<Pet>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@ -35,7 +33,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@ -46,7 +44,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -57,7 +55,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -67,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StoreApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@ -34,7 +32,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||
@ -43,7 +41,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||
@ -52,7 +50,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -62,7 +60,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||
@ -73,7 +71,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||
@ -83,7 +81,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) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||
@ -92,7 +90,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
|
||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -102,6 +100,6 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> logoutUser() {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
@ -34,6 +32,6 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,12 +21,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@ -36,7 +34,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||
@ -44,7 +42,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
|
||||
@ -52,7 +50,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
|
||||
@ -60,7 +58,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
|
||||
@ -70,7 +68,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = {
|
||||
@ -83,7 +81,7 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||
@ -94,7 +92,7 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble);
|
||||
|
||||
|
||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||
@ -103,7 +101,7 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param);
|
||||
|
||||
|
||||
@ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", })
|
||||
@ -112,6 +110,6 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2);
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -18,118 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
@ -36,6 +34,6 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,12 +19,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@ -41,7 +39,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||
@ -55,7 +53,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -70,7 +68,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") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -85,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) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -98,7 +96,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||
@ -115,7 +113,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||
@ -130,7 +128,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ -145,6 +143,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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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") @Valid @RequestPart("file") MultipartFile file);
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -16,106 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PetApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
return new ResponseEntity<Pet>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@ -35,7 +33,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@ -46,7 +44,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -57,7 +55,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -67,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StoreApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@ -34,7 +32,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||
@ -43,7 +41,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||
@ -52,7 +50,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -62,7 +60,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||
@ -73,7 +71,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||
@ -83,7 +81,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) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||
@ -92,7 +90,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
|
||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -102,6 +100,6 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> logoutUser() {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,16 +17,16 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
|
||||
AnotherFakeApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||
@ -35,9 +34,8 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
default ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return getDelegate().testSpecialTags(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,32 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final AnotherFakeApiDelegate delegate;
|
||||
|
||||
@ -35,10 +12,8 @@ public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testSpecialTags(body);
|
||||
@Override
|
||||
public AnotherFakeApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,57 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link AnotherFakeApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link AnotherFakeApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface AnotherFakeApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AnotherFakeApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AnotherFakeApi#testSpecialTags
|
||||
*/
|
||||
default ResponseEntity<Client> testSpecialTags(Client body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ import io.swagger.model.Client;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -22,24 +21,23 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
|
||||
FakeApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
default ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
return getDelegate().fakeOuterBooleanSerialize(body);
|
||||
}
|
||||
|
||||
|
||||
@ -48,9 +46,8 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
default ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
return getDelegate().fakeOuterCompositeSerialize(body);
|
||||
}
|
||||
|
||||
|
||||
@ -59,9 +56,8 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
default ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
return getDelegate().fakeOuterNumberSerialize(body);
|
||||
}
|
||||
|
||||
|
||||
@ -70,9 +66,8 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
default ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
return getDelegate().fakeOuterStringSerialize(body);
|
||||
}
|
||||
|
||||
|
||||
@ -83,9 +78,8 @@ public interface FakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
default ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return getDelegate().testClientModel(body);
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +93,8 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
default 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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default 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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
return getDelegate().testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
}
|
||||
|
||||
|
||||
@ -113,9 +106,8 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
default 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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default 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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
return getDelegate().testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
}
|
||||
|
||||
|
||||
@ -125,9 +117,8 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
return getDelegate().testInlineAdditionalProperties(param);
|
||||
}
|
||||
|
||||
|
||||
@ -137,9 +128,8 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
return getDelegate().testJsonFormData(param, param2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,36 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.model.Client;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final FakeApiDelegate delegate;
|
||||
|
||||
@ -39,79 +12,8 @@ public class FakeApiController implements FakeApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.fakeOuterBooleanSerialize(body);
|
||||
@Override
|
||||
public FakeApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.fakeOuterCompositeSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.fakeOuterNumberSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.fakeOuterStringSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testClientModel(body);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testInlineAdditionalProperties(param);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testJsonFormData(param, param2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,60 +5,133 @@ import io.swagger.model.Client;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link FakeApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link FakeApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface FakeApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(FakeApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#fakeOuterBooleanSerialize
|
||||
*/
|
||||
default ResponseEntity<Boolean> fakeOuterBooleanSerialize(Boolean body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#fakeOuterCompositeSerialize
|
||||
*/
|
||||
default ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(OuterComposite body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#fakeOuterNumberSerialize
|
||||
*/
|
||||
default ResponseEntity<BigDecimal> fakeOuterNumberSerialize(BigDecimal body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#fakeOuterStringSerialize
|
||||
*/
|
||||
default ResponseEntity<String> fakeOuterStringSerialize(String body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#testClientModel
|
||||
*/
|
||||
default ResponseEntity<Client> testClientModel(Client body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,8 +151,11 @@ public interface FakeApiDelegate {
|
||||
OffsetDateTime dateTime,
|
||||
String password,
|
||||
String paramCallback) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,16 +169,22 @@ public interface FakeApiDelegate {
|
||||
String enumQueryString,
|
||||
Integer enumQueryInteger,
|
||||
Double enumQueryDouble) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeApi#testInlineAdditionalProperties
|
||||
*/
|
||||
default ResponseEntity<Void> testInlineAdditionalProperties(Object param) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,8 +192,11 @@ public interface FakeApiDelegate {
|
||||
*/
|
||||
default ResponseEntity<Void> testJsonFormData(String param,
|
||||
String param2) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,16 +17,16 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
|
||||
FakeClassnameTestApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "", response = Client.class, authorizations = {
|
||||
@Authorization(value = "api_key_query")
|
||||
}, tags={ "fake_classname_tags 123#$%^", })
|
||||
@ -37,9 +36,8 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
default ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return getDelegate().testClassname(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,32 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final FakeClassnameTestApiDelegate delegate;
|
||||
|
||||
@ -35,10 +12,8 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.testClassname(body);
|
||||
@Override
|
||||
public FakeClassnameTestApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,57 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link FakeClassnameTestApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link FakeClassnameTestApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface FakeClassnameTestApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FakeClassnameTestApi#testClassname
|
||||
*/
|
||||
default ResponseEntity<Client> testClassname(Client body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -20,16 +19,16 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
|
||||
PetApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@ -42,9 +41,8 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
return getDelegate().addPet(body);
|
||||
}
|
||||
|
||||
|
||||
@ -59,9 +57,8 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default 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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default 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) {
|
||||
return getDelegate().deletePet(petId, apiKey);
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +74,8 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
default ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
return getDelegate().findPetsByStatus(status);
|
||||
}
|
||||
|
||||
|
||||
@ -95,9 +91,8 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
default ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
return getDelegate().findPetsByTags(tags);
|
||||
}
|
||||
|
||||
|
||||
@ -111,9 +106,8 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
default ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
return getDelegate().getPetById(petId);
|
||||
}
|
||||
|
||||
|
||||
@ -131,9 +125,8 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
default ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
return getDelegate().updatePet(body);
|
||||
}
|
||||
|
||||
|
||||
@ -149,9 +142,8 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
default 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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default 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) {
|
||||
return getDelegate().updatePetWithForm(petId, name, status);
|
||||
}
|
||||
|
||||
|
||||
@ -167,9 +159,8 @@ public interface PetApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "multipart/form-data" },
|
||||
method = RequestMethod.POST)
|
||||
default 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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
default 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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
return getDelegate().uploadFile(petId, additionalMetadata, file);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final PetApiDelegate delegate;
|
||||
|
||||
@ -37,57 +12,8 @@ public class PetApiController implements PetApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.addPet(body);
|
||||
@Override
|
||||
public PetApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.deletePet(petId, apiKey);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.findPetsByStatus(status);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.findPetsByTags(tags);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.getPetById(petId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.updatePet(body);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.updatePetWithForm(petId, name, status);
|
||||
}
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.uploadFile(petId, additionalMetadata, file);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,28 +3,49 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link PetApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link PetApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface PetApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(PetApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PetApi#addPet
|
||||
*/
|
||||
default ResponseEntity<Void> addPet(Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,40 +53,103 @@ public interface PetApiDelegate {
|
||||
*/
|
||||
default ResponseEntity<Void> deletePet(Long petId,
|
||||
String apiKey) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PetApi#findPetsByStatus
|
||||
*/
|
||||
default ResponseEntity<List<Pet>> findPetsByStatus(List<String> status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PetApi#findPetsByTags
|
||||
*/
|
||||
default ResponseEntity<List<Pet>> findPetsByTags(List<String> tags) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PetApi#getPetById
|
||||
*/
|
||||
default ResponseEntity<Pet> getPetById(Long petId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>", Pet.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PetApi#updatePet
|
||||
*/
|
||||
default ResponseEntity<Void> updatePet(Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,8 +158,11 @@ public interface PetApiDelegate {
|
||||
default ResponseEntity<Void> updatePetWithForm(Long petId,
|
||||
String name,
|
||||
String status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,8 +171,19 @@ public interface PetApiDelegate {
|
||||
default ResponseEntity<ModelApiResponse> uploadFile(Long petId,
|
||||
String additionalMetadata,
|
||||
MultipartFile file) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,10 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,16 +18,16 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
|
||||
StoreApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "Delete purchase order by ID", nickname = "deleteOrder", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ -36,9 +35,8 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
return getDelegate().deleteOrder(orderId);
|
||||
}
|
||||
|
||||
|
||||
@ -50,9 +48,8 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
default ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
return getDelegate().getInventory();
|
||||
}
|
||||
|
||||
|
||||
@ -64,9 +61,8 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
default ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) {
|
||||
return getDelegate().getOrderById(orderId);
|
||||
}
|
||||
|
||||
|
||||
@ -77,9 +73,8 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
default ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
return getDelegate().placeOrder(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final StoreApiDelegate delegate;
|
||||
|
||||
@ -36,27 +12,8 @@ public class StoreApiController implements StoreApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.deleteOrder(orderId);
|
||||
@Override
|
||||
public StoreApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.getInventory();
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.getOrderById(orderId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.placeOrder(body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,52 +2,122 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link StoreApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link StoreApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface StoreApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(StoreApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StoreApi#deleteOrder
|
||||
*/
|
||||
default ResponseEntity<Void> deleteOrder(String orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StoreApi#getInventory
|
||||
*/
|
||||
default ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StoreApi#getOrderById
|
||||
*/
|
||||
default ResponseEntity<Order> getOrderById(Long orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see StoreApi#placeOrder
|
||||
*/
|
||||
default ResponseEntity<Order> placeOrder(Order body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,10 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,25 +18,24 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
|
||||
UserApiDelegate getDelegate();
|
||||
|
||||
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
return getDelegate().createUser(body);
|
||||
}
|
||||
|
||||
|
||||
@ -47,9 +45,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
return getDelegate().createUsersWithArrayInput(body);
|
||||
}
|
||||
|
||||
|
||||
@ -59,9 +56,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
default ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
return getDelegate().createUsersWithListInput(body);
|
||||
}
|
||||
|
||||
|
||||
@ -72,9 +68,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
default ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
||||
return getDelegate().deleteUser(username);
|
||||
}
|
||||
|
||||
|
||||
@ -86,9 +81,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
default ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
return getDelegate().getUserByName(username);
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +93,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/login",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
default ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
return getDelegate().loginUser(username, password);
|
||||
}
|
||||
|
||||
|
||||
@ -111,9 +104,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
default ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default ResponseEntity<Void> logoutUser() {
|
||||
return getDelegate().logoutUser();
|
||||
}
|
||||
|
||||
|
||||
@ -124,9 +116,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
default 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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
default 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) {
|
||||
return getDelegate().updateUser(username, body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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 java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final UserApiDelegate delegate;
|
||||
|
||||
@ -36,53 +12,8 @@ public class UserApiController implements UserApi {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.createUser(body);
|
||||
@Override
|
||||
public UserApiDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.createUsersWithArrayInput(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.createUsersWithListInput(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.deleteUser(username);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.getUserByName(username);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.loginUser(username, password);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.logoutUser();
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return delegate.updateUser(username, body);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,60 +2,109 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link UserApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link UserApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface UserApiDelegate {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(UserApi.class);
|
||||
|
||||
default Optional<ObjectMapper> getObjectMapper() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default Optional<String> getAcceptHeader() {
|
||||
return getRequest().map(r -> r.getHeader("Accept"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#createUser
|
||||
*/
|
||||
default ResponseEntity<Void> createUser(User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#createUsersWithArrayInput
|
||||
*/
|
||||
default ResponseEntity<Void> createUsersWithArrayInput(List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#createUsersWithListInput
|
||||
*/
|
||||
default ResponseEntity<Void> createUsersWithListInput(List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#deleteUser
|
||||
*/
|
||||
default ResponseEntity<Void> deleteUser(String username) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#getUserByName
|
||||
*/
|
||||
default ResponseEntity<User> getUserByName(String username) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,16 +112,38 @@ public interface UserApiDelegate {
|
||||
*/
|
||||
default ResponseEntity<String> loginUser(String username,
|
||||
String password) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
if (getAcceptHeader().get().contains("application/xml")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
if (getAcceptHeader().get().contains("application/json")) {
|
||||
try {
|
||||
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserApi#logoutUser
|
||||
*/
|
||||
default ResponseEntity<Void> logoutUser() {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,8 +151,11 @@ public interface UserApiDelegate {
|
||||
*/
|
||||
default ResponseEntity<Void> updateUser(String username,
|
||||
User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
} else {
|
||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
@ -34,6 +32,6 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,19 +14,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final AnotherFakeApiDelegate delegate;
|
||||
|
||||
@ -34,10 +27,7 @@ public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
public AnotherFakeApiController(AnotherFakeApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return delegate.testSpecialTags(body);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -10,8 +9,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link AnotherFakeApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link AnotherFakeApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface AnotherFakeApiDelegate {
|
||||
|
@ -10,9 +10,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,12 +21,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@ -36,7 +34,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||
@ -44,7 +42,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
|
||||
@ -52,7 +50,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
|
||||
@ -60,7 +58,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
|
||||
@ -70,7 +68,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = {
|
||||
@ -83,7 +81,7 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||
@ -94,7 +92,7 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble);
|
||||
|
||||
|
||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||
@ -103,7 +101,7 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param);
|
||||
|
||||
|
||||
@ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", })
|
||||
@ -112,6 +110,6 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2);
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -18,19 +18,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final FakeApiDelegate delegate;
|
||||
|
||||
@ -38,79 +31,39 @@ public class FakeApiController implements FakeApi {
|
||||
public FakeApiController(FakeApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
return delegate.fakeOuterBooleanSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
return delegate.fakeOuterCompositeSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
return delegate.fakeOuterNumberSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
return delegate.fakeOuterStringSerialize(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return delegate.testClientModel(body);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
return delegate.testInlineAdditionalProperties(param);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
return delegate.testJsonFormData(param, param2);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -14,8 +13,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link FakeApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link FakeApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface FakeApiDelegate {
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
@ -36,6 +34,6 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,19 +14,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final FakeClassnameTestApiDelegate delegate;
|
||||
|
||||
@ -34,10 +27,7 @@ public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
public FakeClassnameTestApiController(FakeClassnameTestApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
return delegate.testClassname(body);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -10,8 +9,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link FakeClassnameTestApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link FakeClassnameTestApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface FakeClassnameTestApiDelegate {
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,12 +19,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@ -41,7 +39,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||
@ -55,7 +53,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -70,7 +68,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") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -85,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) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -98,7 +96,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||
@ -115,7 +113,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||
@ -130,7 +128,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ -145,6 +143,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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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") @Valid @RequestPart("file") MultipartFile file);
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -16,19 +16,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final PetApiDelegate delegate;
|
||||
|
||||
@ -36,57 +29,35 @@ public class PetApiController implements PetApi {
|
||||
public PetApiController(PetApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
return delegate.addPet(body);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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) {
|
||||
return delegate.deletePet(petId, apiKey);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
return delegate.findPetsByStatus(status);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
return delegate.findPetsByTags(tags);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
return delegate.getPetById(petId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
return delegate.updatePet(body);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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) {
|
||||
return delegate.updatePetWithForm(petId, name, status);
|
||||
}
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
return delegate.uploadFile(petId, additionalMetadata, file);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -12,8 +11,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link PetApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link PetApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface PetApiDelegate {
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@ -35,7 +33,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@ -46,7 +44,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -57,7 +55,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -67,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,19 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final StoreApiDelegate delegate;
|
||||
|
||||
@ -35,27 +28,19 @@ public class StoreApiController implements StoreApi {
|
||||
public StoreApiController(StoreApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
return delegate.deleteOrder(orderId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
return delegate.getInventory();
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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) {
|
||||
return delegate.getOrderById(orderId);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
return delegate.placeOrder(body);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -11,8 +10,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link StoreApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link StoreApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface StoreApiDelegate {
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@ -34,7 +32,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||
@ -43,7 +41,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||
@ -52,7 +50,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -62,7 +60,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||
@ -73,7 +71,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||
@ -83,7 +81,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) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||
@ -92,7 +90,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
|
||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -102,6 +100,6 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,19 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
private final UserApiDelegate delegate;
|
||||
|
||||
@ -35,53 +28,35 @@ public class UserApiController implements UserApi {
|
||||
public UserApiController(UserApiDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
return delegate.createUser(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
return delegate.createUsersWithArrayInput(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body) {
|
||||
return delegate.createUsersWithListInput(body);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
||||
return delegate.deleteUser(username);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
return delegate.getUserByName(username);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
return delegate.loginUser(username, password);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
public ResponseEntity<Void> logoutUser() {
|
||||
return delegate.logoutUser();
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
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) {
|
||||
return delegate.updateUser(username, body);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -11,8 +10,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A delegate to be called by the {@link UserApiController}}.
|
||||
* Should be implemented as a controller but without the {@link org.springframework.stereotype.Controller} annotation.
|
||||
* Instead, use spring to autowire this class into the {@link UserApiController}.
|
||||
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||
*/
|
||||
|
||||
public interface UserApiDelegate {
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
@ -36,6 +34,6 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,12 +21,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@ -38,7 +36,7 @@ public interface FakeApi {
|
||||
})
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||
@ -48,7 +46,7 @@ public interface FakeApi {
|
||||
})
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
|
||||
@ -58,7 +56,7 @@ public interface FakeApi {
|
||||
})
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
|
||||
@ -68,7 +66,7 @@ public interface FakeApi {
|
||||
})
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
|
||||
@ -80,7 +78,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = {
|
||||
@ -95,7 +93,7 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||
@ -110,7 +108,7 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
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 = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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 = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble);
|
||||
|
||||
|
||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||
@ -121,7 +119,7 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param);
|
||||
|
||||
|
||||
@ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", })
|
||||
@ -132,6 +130,6 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2);
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -18,116 +19,115 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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 = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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 = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List<String> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,12 +17,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
@ -38,6 +36,6 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,29 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -19,12 +19,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@ -43,7 +41,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||
@ -60,7 +58,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -77,7 +75,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") @Valid @RequestParam(value = "status", required = true) List<String> status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@ -94,7 +92,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) @Valid @RequestParam(value = "tags", required = true) List<String> tags, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ -109,7 +107,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||
@ -128,7 +126,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||
@ -145,7 +143,7 @@ public interface PetApi {
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ -162,6 +160,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") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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") @Valid @RequestPart("file") MultipartFile file);
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package io.swagger.api;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -16,105 +17,128 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PetApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PetApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<List<Pet>>(objectMapper.readValue("[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Pet>(objectMapper.readValue("{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Pet>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
return new ResponseEntity<Pet>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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") @Valid @RequestPart("file") MultipartFile file) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<ModelApiResponse>(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@ -37,7 +35,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{order_id}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@ -50,7 +48,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ -63,7 +61,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||
@ -75,6 +73,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.Map;
|
||||
import io.swagger.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,66 +16,90 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StoreApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public StoreApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Map<String, Integer>>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Order>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -18,12 +18,10 @@ 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 org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@ -36,7 +34,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||
@ -47,7 +45,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||
@ -58,7 +56,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -70,7 +68,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||
@ -83,7 +81,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||
@ -95,7 +93,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) @Valid @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||
@ -106,7 +104,7 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser( @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
|
||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||
@ -118,6 +116,6 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.PUT)
|
||||
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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package io.swagger.api;
|
||||
|
||||
import java.util.List;
|
||||
import io.swagger.model.User;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -15,87 +16,101 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public UserApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
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);
|
||||
try {
|
||||
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.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull@ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/xml")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("aeiou", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/xml", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> logoutUser(@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> logoutUser() {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,13 +17,11 @@ 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 javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(value = "another-fake", description = "the another-fake API")
|
||||
public interface AnotherFakeApi {
|
||||
@ -35,6 +33,6 @@ public interface AnotherFakeApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,30 +15,40 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -21,13 +21,11 @@ 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 javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@ -37,7 +35,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||
@RequestMapping(value = "/fake/outer/boolean",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||
@ -45,7 +43,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) })
|
||||
@RequestMapping(value = "/fake/outer/composite",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterNumberSerialize", notes = "Test serialization of outer number types", response = BigDecimal.class, tags={ "fake", })
|
||||
@ -53,7 +51,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) })
|
||||
@RequestMapping(value = "/fake/outer/number",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
|
||||
|
||||
|
||||
@ApiOperation(value = "", nickname = "fakeOuterStringSerialize", notes = "Test serialization of outer string types", response = String.class, tags={ "fake", })
|
||||
@ -61,7 +59,7 @@ public interface FakeApi {
|
||||
@ApiResponse(code = 200, message = "Output string", response = String.class) })
|
||||
@RequestMapping(value = "/fake/outer/string",
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
|
||||
@ -71,7 +69,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, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", nickname = "testEndpointParameters", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = {
|
||||
@ -84,7 +82,7 @@ public interface FakeApi {
|
||||
produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" },
|
||||
method = RequestMethod.POST)
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback);
|
||||
|
||||
|
||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||
@ -95,7 +93,7 @@ public interface FakeApi {
|
||||
produces = { "*/*" },
|
||||
consumes = { "*/*" },
|
||||
method = RequestMethod.GET)
|
||||
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) Optional<List<String>> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional<String> enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional<List<String>> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional<String> enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional<Integer> enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
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) Optional<List<String>> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional<String> enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional<List<String>> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional<String> enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional<Integer> enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble);
|
||||
|
||||
|
||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||
@ -104,7 +102,7 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/inline-additionalProperties",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param);
|
||||
|
||||
|
||||
@ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", })
|
||||
@ -113,6 +111,6 @@ public interface FakeApi {
|
||||
@RequestMapping(value = "/fake/jsonFormData",
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2);
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,10 @@ import io.swagger.model.Client;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.model.OuterComposite;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -18,119 +19,116 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Boolean>(objectMapper.readValue("{ }", Boolean.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Boolean>(HttpStatus.OK);
|
||||
return new ResponseEntity<Boolean>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<OuterComposite>(objectMapper.readValue("{ \"my_string\" : { }, \"my_number\" : { }, \"my_boolean\" : { }}", OuterComposite.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.OK);
|
||||
return new ResponseEntity<OuterComposite>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<BigDecimal>(objectMapper.readValue("{ }", BigDecimal.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.OK);
|
||||
return new ResponseEntity<BigDecimal>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<String>(objectMapper.readValue("{ }", String.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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,
|
||||
@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,
|
||||
@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,
|
||||
@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,
|
||||
@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,
|
||||
@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,
|
||||
@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,
|
||||
@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,
|
||||
@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,
|
||||
@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,
|
||||
@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,
|
||||
@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(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,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
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) Optional<List<String>> enumHeaderStringArray,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional<String> enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional<List<String>> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional<String> enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional<Integer> enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// 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) Optional<List<String>> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional<String> enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional<List<String>> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional<String> enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional<Integer> enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,
|
||||
@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2) {
|
||||
String accept = request.getHeader("Accept");
|
||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -17,13 +17,11 @@ 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 javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
@ -37,6 +35,6 @@ public interface FakeClassnameTestApi {
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception;
|
||||
ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -14,30 +15,40 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Optional;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class);
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper) {
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Autowired
|
||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
|
||||
@RequestHeader(value = "Accept", required = false) String accept) throws Exception {
|
||||
// do some magic!
|
||||
|
||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
|
||||
String accept = request.getHeader("Accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.OK);
|
||||
try {
|
||||
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"client\"}", Client.class), HttpStatus.NOT_IMPLEMENTED);
|
||||
} catch (IOException e) {
|
||||
log.error("Couldn't serialize response for content type application/json", e);
|
||||
return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<Client>(HttpStatus.OK);
|
||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user