mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Add reactive option for Spring Boot (webflux)
This commit is contained in:
parent
e2251084f2
commit
1619486578
@ -13,6 +13,7 @@
|
|||||||
./bin/spring-delegate.sh
|
./bin/spring-delegate.sh
|
||||||
./bin/spring-delegate-j8.sh
|
./bin/spring-delegate-j8.sh
|
||||||
./bin/springboot-petstore-server.sh
|
./bin/springboot-petstore-server.sh
|
||||||
|
./bin/springboot-petstore-server-reactive.sh
|
||||||
./bin/springboot-petstore-server-beanvalidation.sh
|
./bin/springboot-petstore-server-beanvalidation.sh
|
||||||
./bin/springboot-petstore-server-implicitHeaders.sh
|
./bin/springboot-petstore-server-implicitHeaders.sh
|
||||||
./bin/springboot-petstore-server-useOptional.sh
|
./bin/springboot-petstore-server-useOptional.sh
|
||||||
|
@ -27,7 +27,7 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate --artifact-id springboot-delegate-j8 -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate-j8 -DdelegatePattern=true,hideGenerationTimestamp=true,java8=true"
|
ags="$@ generate --artifact-id springboot-delegate-j8 -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate-j8 -DdelegatePattern=true,hideGenerationTimestamp=true"
|
||||||
|
|
||||||
echo "Removing files and folders under samples/server/petstore/springboot-delegate-j8/src/main"
|
echo "Removing files and folders under samples/server/petstore/springboot-delegate-j8/src/main"
|
||||||
rm -rf samples/server/petstore/springboot-delegate-j8/src/main
|
rm -rf samples/server/petstore/springboot-delegate-j8/src/main
|
||||||
|
@ -27,7 +27,7 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate --artifact-id springboot-delegate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate -DdelegatePattern=true,hideGenerationTimestamp=true"
|
ags="$@ generate --artifact-id springboot-delegate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate -DdelegatePattern=true,hideGenerationTimestamp=true,java8=false"
|
||||||
|
|
||||||
echo "Removing files and folders under samples/server/petstore/springboot-delegate/src/main"
|
echo "Removing files and folders under samples/server/petstore/springboot-delegate/src/main"
|
||||||
rm -rf samples/server/petstore/springboot-delegate/src/main
|
rm -rf samples/server/petstore/springboot-delegate/src/main
|
||||||
|
@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true --additional-properties serverPort=8002"
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,async=true --additional-properties serverPort=8002"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/spring-mvc-petstore-server.json -o samples/server/petstore/spring-mvc -DhideGenerationTimestamp=true --additional-properties serverPort=8002"
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/spring-mvc-petstore-server.json -o samples/server/petstore/spring-mvc -DhideGenerationTimestamp=true,java8=false --additional-properties serverPort=8002"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -27,7 +27,7 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-beanvalidation -c bin/springboot-petstore-server-beanvalidation.json -DhideGenerationTimestamp=true"
|
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-beanvalidation -c bin/springboot-petstore-server-beanvalidation.json -DhideGenerationTimestamp=true,java8=false"
|
||||||
|
|
||||||
echo "Removing files and folders under samples/server/petstore/springboot-beanvalidation/src/main"
|
echo "Removing files and folders under samples/server/petstore/springboot-beanvalidation/src/main"
|
||||||
rm -rf samples/server/petstore/springboot-beanvalidation/src/main
|
rm -rf samples/server/petstore/springboot-beanvalidation/src/main
|
||||||
|
34
bin/springboot-petstore-server-reactive.sh
Executable file
34
bin/springboot-petstore-server-reactive.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate --artifact-id springboot-reactive -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-reactive -Dreactive=true,hideGenerationTimestamp=true $@"
|
||||||
|
|
||||||
|
echo "Removing files and folders under samples/server/petstore/springboot-reactive/src/main"
|
||||||
|
rm -rf samples/server/petstore/springboot-reactive/src/main
|
||||||
|
find samples/server/petstore/springboot-reactive -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -61,6 +61,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||||
public static final String JAVA_8 = "java8";
|
public static final String JAVA_8 = "java8";
|
||||||
public static final String ASYNC = "async";
|
public static final String ASYNC = "async";
|
||||||
|
public static final String REACTIVE = "reactive";
|
||||||
public static final String RESPONSE_WRAPPER = "responseWrapper";
|
public static final String RESPONSE_WRAPPER = "responseWrapper";
|
||||||
public static final String USE_TAGS = "useTags";
|
public static final String USE_TAGS = "useTags";
|
||||||
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
||||||
@ -75,8 +76,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
protected boolean delegatePattern = false;
|
protected boolean delegatePattern = false;
|
||||||
protected boolean delegateMethod = false;
|
protected boolean delegateMethod = false;
|
||||||
protected boolean singleContentTypes = false;
|
protected boolean singleContentTypes = false;
|
||||||
protected boolean java8 = false;
|
protected boolean java8 = true;
|
||||||
protected boolean async = false;
|
protected boolean async = false;
|
||||||
|
protected boolean reactive = false;
|
||||||
protected String responseWrapper = "";
|
protected String responseWrapper = "";
|
||||||
protected boolean useTags = false;
|
protected boolean useTags = false;
|
||||||
protected boolean useBeanValidation = true;
|
protected boolean useBeanValidation = true;
|
||||||
@ -105,6 +107,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation."));
|
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation."));
|
||||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
|
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
|
||||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
|
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
|
||||||
|
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)"));
|
||||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
||||||
@ -147,12 +150,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
if (additionalProperties.containsKey(JAVA_8)) {
|
if (additionalProperties.containsKey(JAVA_8)) {
|
||||||
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
||||||
}
|
}
|
||||||
if (this.java8) {
|
if (this.java8 && !additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||||
additionalProperties.put("javaVersion", "1.8");
|
setDateLibrary("java8");
|
||||||
additionalProperties.put("jdk8", "true");
|
|
||||||
if (!additionalProperties.containsKey(DATE_LIBRARY)) {
|
|
||||||
setDateLibrary("java8");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!additionalProperties.containsKey(BASE_PACKAGE) && additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
if (!additionalProperties.containsKey(BASE_PACKAGE) && additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||||
@ -198,14 +197,17 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
|
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(JAVA_8)) {
|
|
||||||
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(ASYNC)) {
|
if (additionalProperties.containsKey(ASYNC)) {
|
||||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(REACTIVE)) {
|
||||||
|
if (!library.equals(DEFAULT_LIBRARY)) {
|
||||||
|
throw new IllegalArgumentException("Currently, reactive option is only supported with Spring-boot");
|
||||||
|
}
|
||||||
|
this.setReactive(Boolean.valueOf(additionalProperties.get(REACTIVE).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(RESPONSE_WRAPPER)) {
|
if (additionalProperties.containsKey(RESPONSE_WRAPPER)) {
|
||||||
this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER));
|
this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER));
|
||||||
}
|
}
|
||||||
@ -256,10 +258,11 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
|
||||||
if (!this.interfaceOnly) {
|
if (!this.interfaceOnly) {
|
||||||
|
|
||||||
if (library.equals(DEFAULT_LIBRARY)) {
|
if (library.equals(DEFAULT_LIBRARY)) {
|
||||||
supportingFiles.add(new SupportingFile("homeController.mustache",
|
if (!this.reactive) {
|
||||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
supportingFiles.add(new SupportingFile("homeController.mustache",
|
||||||
|
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
||||||
|
}
|
||||||
supportingFiles.add(new SupportingFile("openapi2SpringBoot.mustache",
|
supportingFiles.add(new SupportingFile("openapi2SpringBoot.mustache",
|
||||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "OpenAPI2SpringBoot.java"));
|
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "OpenAPI2SpringBoot.java"));
|
||||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||||
@ -297,16 +300,23 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
||||||
supportingFiles.add(new SupportingFile("notFoundException.mustache",
|
supportingFiles.add(new SupportingFile("notFoundException.mustache",
|
||||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
||||||
supportingFiles.add(new SupportingFile("apiOriginFilter.mustache",
|
if (!this.reactive) {
|
||||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
supportingFiles.add(new SupportingFile("apiOriginFilter.mustache",
|
||||||
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
||||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
||||||
|
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ( this.swaggerDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY)) {
|
} else if (this.swaggerDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY) && !this.reactive) {
|
||||||
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
|
||||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "OpenAPIDocumentationConfig.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SPRING_CLOUD_LIBRARY.equals(library)) {
|
||||||
|
supportingFiles.add(new SupportingFile("apiUtil.mustache",
|
||||||
|
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtil.java"));
|
||||||
|
}
|
||||||
|
|
||||||
if ("threetenbp".equals(dateLibrary)) {
|
if ("threetenbp".equals(dateLibrary)) {
|
||||||
supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache",
|
supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache",
|
||||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java"));
|
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java"));
|
||||||
@ -328,7 +338,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
|
|
||||||
if (this.java8) {
|
if (this.java8) {
|
||||||
additionalProperties.put("javaVersion", "1.8");
|
additionalProperties.put("javaVersion", "1.8");
|
||||||
additionalProperties.put("jdk8", "true");
|
if (!SPRING_CLOUD_LIBRARY.equals(library)) {
|
||||||
|
additionalProperties.put("jdk8", "true");
|
||||||
|
}
|
||||||
if (this.async) {
|
if (this.async) {
|
||||||
additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture");
|
additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture");
|
||||||
}
|
}
|
||||||
@ -341,7 +353,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
case "Future":
|
case "Future":
|
||||||
case "Callable":
|
case "Callable":
|
||||||
case "CompletableFuture":
|
case "CompletableFuture":
|
||||||
additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent" + this.responseWrapper);
|
additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent." + this.responseWrapper);
|
||||||
break;
|
break;
|
||||||
case "ListenableFuture":
|
case "ListenableFuture":
|
||||||
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture");
|
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture");
|
||||||
@ -647,6 +659,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
|
|
||||||
public void setAsync(boolean async) { this.async = async; }
|
public void setAsync(boolean async) { this.async = async; }
|
||||||
|
|
||||||
|
public void setReactive(boolean reactive) { this.reactive = reactive; }
|
||||||
|
|
||||||
public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; }
|
public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; }
|
||||||
|
|
||||||
public void setUseTags(boolean useTags) {
|
public void setUseTags(boolean useTags) {
|
||||||
|
@ -7,19 +7,12 @@ package {{package}};
|
|||||||
|
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
{{#jdk8-no-delegate}}
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
{{/jdk8-no-delegate}}
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
{{#jdk8-no-delegate}}
|
{{#jdk8-no-delegate}}
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
{{/jdk8-no-delegate}}
|
{{/jdk8-no-delegate}}
|
||||||
import org.springframework.http.ResponseEntity;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -27,19 +20,24 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
{{#jdk8-no-delegate}}
|
{{#jdk8-no-delegate}}
|
||||||
import javax.servlet.http.HttpServletRequest;
|
{{^reactive}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
{{/reactive}}
|
||||||
{{/jdk8-no-delegate}}
|
{{/jdk8-no-delegate}}
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
{{#reactive}}
|
||||||
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
{{#jdk8-no-delegate}}
|
|
||||||
import java.io.IOException;
|
|
||||||
{{/jdk8-no-delegate}}
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
{{#jdk8-no-delegate}}
|
{{#jdk8-no-delegate}}
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/jdk8-no-delegate}}
|
{{/jdk8-no-delegate}}
|
||||||
@ -56,21 +54,13 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
public interface {{classname}} {
|
public interface {{classname}} {
|
||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
|
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
Logger log = LoggerFactory.getLogger({{classname}}.class);
|
{{^reactive}}
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
{{/reactive}}
|
||||||
default Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
default Optional<String> getAcceptHeader() {
|
|
||||||
return getRequest().map(r -> r.getHeader("Accept"));
|
|
||||||
}
|
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
{{#isDelegate}}
|
{{#isDelegate}}
|
||||||
{{classname}}Delegate getDelegate();
|
{{classname}}Delegate getDelegate();
|
||||||
@ -100,33 +90,19 @@ public interface {{classname}} {
|
|||||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
method = RequestMethod.{{httpMethod}})
|
method = RequestMethod.{{httpMethod}})
|
||||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||||
{{#delegate-method}}
|
{{#delegate-method}}
|
||||||
return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override this method
|
// Override this method
|
||||||
default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}) {
|
||||||
{{/delegate-method}}
|
{{/delegate-method}}
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
{{>methodBody}}
|
||||||
{{#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}}
|
||||||
{{#isDelegate}}
|
{{#isDelegate}}
|
||||||
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}, exchange{{/reactive}});
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
}{{/jdk8}}
|
}{{/jdk8}}
|
||||||
|
|
||||||
|
@ -3,15 +3,9 @@ package {{package}};
|
|||||||
{{^jdk8}}
|
{{^jdk8}}
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
{{/jdk8}}
|
|
||||||
{{^isDelegate}}
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
{{/isDelegate}}
|
|
||||||
{{^jdk8}}
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -21,6 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
{{/jdk8}}
|
||||||
|
{{^isDelegate}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
{{/isDelegate}}
|
||||||
|
{{^jdk8}}
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
@ -28,22 +27,17 @@ import javax.validation.constraints.*;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
{{^isDelegate}}
|
{{#jdk8-no-delegate}}
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
{{#jdk8}}
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/jdk8}}
|
{{/jdk8-no-delegate}}
|
||||||
{{/isDelegate}}
|
|
||||||
{{^jdk8-no-delegate}}
|
{{^jdk8-no-delegate}}
|
||||||
{{#useOptional}}
|
{{#useOptional}}
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/useOptional}}
|
{{/useOptional}}
|
||||||
{{/jdk8-no-delegate}}
|
{{/jdk8-no-delegate}}
|
||||||
{{^jdk8}}
|
{{^jdk8}}
|
||||||
{{^isDelegate}}
|
|
||||||
import java.io.IOException;
|
|
||||||
{{/isDelegate}}
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
{{#async}}
|
{{#async}}
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
{{/async}}
|
{{/async}}
|
||||||
@ -69,76 +63,42 @@ public class {{classname}}Controller implements {{classname}} {
|
|||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
{{^jdk8}}
|
{{^reactive}}
|
||||||
private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
{{/jdk8}}
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) {
|
public {{classname}}Controller(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
{{^jdk8}}
|
{{^jdk8}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
{{^async}}
|
{{^async}}
|
||||||
String accept = request.getHeader("Accept");
|
{{>methodBody}}
|
||||||
{{#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}}
|
{{/async}}
|
||||||
{{#async}}
|
{{#async}}
|
||||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<{{>returnTypes}}> call() {
|
public ResponseEntity<{{>returnTypes}}> call() {
|
||||||
String accept = request.getHeader("Accept");
|
{{>methodBody}}
|
||||||
{{#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}}
|
{{/async}}
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
{{#isDelegate}}
|
{{#isDelegate}}
|
||||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
{{/isDelegate}}
|
{{/isDelegate}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -2,25 +2,19 @@ package {{package}};
|
|||||||
|
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
{{#jdk8}}
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
{{/jdk8}}
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
{{#jdk8}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
{{/jdk8}}
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
{{#jdk8}}
|
|
||||||
import java.io.IOException;
|
|
||||||
{{/jdk8}}
|
|
||||||
|
|
||||||
{{#jdk8}}
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
{{/jdk8}}
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
@ -42,19 +36,9 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
|
|||||||
public interface {{classname}}Delegate {
|
public interface {{classname}}Delegate {
|
||||||
{{#jdk8}}
|
{{#jdk8}}
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger({{classname}}.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
default Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
default Optional<String> getAcceptHeader() {
|
|
||||||
return getRequest().map(r -> r.getHeader("Accept"));
|
|
||||||
}
|
|
||||||
{{/jdk8}}
|
{{/jdk8}}
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
@ -62,22 +46,9 @@ public interface {{classname}}Delegate {
|
|||||||
* @see {{classname}}#{{operationId}}
|
* @see {{classname}}#{{operationId}}
|
||||||
*/
|
*/
|
||||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},
|
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},
|
||||||
{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
{{/hasMore}}{{^hasMore}}{{#reactive}},
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
{{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||||
{{#examples}}
|
{{>methodBody}}
|
||||||
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}}
|
}{{/jdk8}}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
{{#reactive}}
|
||||||
|
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||||
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
{{/reactive}}
|
||||||
|
{{^reactive}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
{{^reactive}}
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/reactive}}
|
||||||
|
{{#reactive}}
|
||||||
|
public static Mono<Void> getExampleResponse(ServerWebExchange exchange, String example) {
|
||||||
|
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes())));
|
||||||
|
}
|
||||||
|
{{/reactive}}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
springfox.documentation.swagger.v2.path=/api-docs
|
springfox.documentation.swagger.v2.path=/api-docs
|
||||||
server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
|
server.{{#java8}}servlet.{{/java8}}context-path={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
|
||||||
server.port={{serverPort}}
|
server.port={{serverPort}}
|
||||||
spring.jackson.date-format={{basePackage}}.RFC3339DateFormat
|
spring.jackson.date-format={{basePackage}}.RFC3339DateFormat
|
||||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
@ -1 +1 @@
|
|||||||
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
|
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}} {{paramName}}{{/isBodyParam}}
|
@ -1 +1 @@
|
|||||||
{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
{{#returnContainer}}{{#isMapContainer}}Map<String, {{/isMapContainer}}{{#isListContainer}}List<{{/isListContainer}}{{{returnType}}}>{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
@ -10,11 +10,13 @@ This is an example of building a OpenAPI-enabled server in Java using the Spring
|
|||||||
|
|
||||||
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
|
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
|
||||||
|
|
||||||
Start your server as an simple java application
|
Start your server as an simple java application
|
||||||
|
|
||||||
|
{{#reactive}}
|
||||||
You can view the api documentation in swagger-ui by pointing to
|
You can view the api documentation in swagger-ui by pointing to
|
||||||
http://localhost:8080/
|
http://localhost:8080/
|
||||||
|
|
||||||
|
{{/reactive}}
|
||||||
Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}}
|
Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}}
|
||||||
# OpenAPI generated API stub
|
# OpenAPI generated API stub
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableSwagger2
|
|
||||||
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
|
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
|
||||||
public class OpenAPI2SpringBoot implements CommandLineRunner {
|
public class OpenAPI2SpringBoot implements CommandLineRunner {
|
||||||
|
|
||||||
|
@ -9,12 +9,14 @@
|
|||||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<springfox-version>2.7.0</springfox-version>
|
{{^reactive}}
|
||||||
|
<springfox-version>2.8.0</springfox-version>
|
||||||
|
{{/reactive}}
|
||||||
</properties>
|
</properties>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>{{#java8}}2.0.1.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}}</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
@ -37,12 +39,9 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web{{#reactive}}flux{{/reactive}}</artifactId>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{^reactive}}
|
||||||
<!--SpringFox dependencies -->
|
<!--SpringFox dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
@ -54,6 +53,14 @@
|
|||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${springfox-version}</version>
|
<version>${springfox-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/reactive}}
|
||||||
|
{{#reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.5.14</version>
|
||||||
|
</dependency>
|
||||||
|
{{/reactive}}
|
||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
|
|
||||||
<!-- XML processing: Jackson -->
|
<!-- XML processing: Jackson -->
|
||||||
|
@ -21,7 +21,6 @@ import org.threeten.bp.Instant;
|
|||||||
import org.threeten.bp.OffsetDateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
import org.threeten.bp.ZonedDateTime;
|
import org.threeten.bp.ZonedDateTime;
|
||||||
{{/threetenbp}}
|
{{/threetenbp}}
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = "{{apiPackage}}")
|
@ComponentScan(basePackages = "{{apiPackage}}")
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
|
||||||
@PropertySource("classpath:swagger.properties")
|
@PropertySource("classpath:swagger.properties")
|
||||||
@Import(OpenAPIDocumentationConfig.class)
|
@Import(OpenAPIDocumentationConfig.class)
|
||||||
public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter {
|
public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
{{^reactive}}
|
||||||
|
{{#examples}}
|
||||||
|
{{#-first}}
|
||||||
|
{{#jdk8}}
|
||||||
|
{{#async}}
|
||||||
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
|
{{/async}}getRequest().ifPresent(request -> {
|
||||||
|
{{#async}} {{/async}} {{/jdk8}}for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
{{/-first}}
|
||||||
|
{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
||||||
|
{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} ApiUtil.setExampleResponse(request, "{{{contentType}}}", "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}");
|
||||||
|
{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} break;
|
||||||
|
{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} }
|
||||||
|
{{#-last}}
|
||||||
|
{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} }
|
||||||
|
{{#jdk8}}
|
||||||
|
{{#async}} {{/async}} });
|
||||||
|
{{/jdk8}}
|
||||||
|
{{#async}} {{/async}} return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
{{#jdk8}}
|
||||||
|
{{#async}}
|
||||||
|
}, Runnable::run);
|
||||||
|
{{/async}}
|
||||||
|
{{/jdk8}}
|
||||||
|
{{/-last}}
|
||||||
|
{{/examples}}
|
||||||
|
{{^examples}}
|
||||||
|
return {{#jdk8}}{{#async}}CompletableFuture.completedFuture({{/async}}{{/jdk8}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#jdk8}}{{#async}}){{/async}}{{/jdk8}};
|
||||||
|
{{/examples}}
|
||||||
|
{{/reactive}}
|
||||||
|
{{#reactive}}
|
||||||
|
{{>returnTypes}} result = {{#isListContainer}}Flux{{/isListContainer}}{{^isListContainer}}Mono{{/isListContainer}}.empty();
|
||||||
|
{{#examples}}
|
||||||
|
{{#-first}}
|
||||||
|
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||||
|
{{/-first}}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
||||||
|
result = ApiUtil.getExampleResponse(exchange, "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}")
|
||||||
|
.then{{#isListContainer}}Many{{/isListContainer}}(Mono.empty());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
{{#-last}}
|
||||||
|
}
|
||||||
|
{{/-last}}
|
||||||
|
{{/examples}}
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body({{^isListContainer}}{{#allParams}}{{#isBodyParam}}{{paramName}}.then({{/isBodyParam}}{{/allParams}}{{/isListContainer}}{{#isListContainer}}{{#allParams}}{{#isBodyParam}}{{paramName}}.thenMany({{/isBodyParam}}{{/allParams}}{{/isListContainer}}result{{#allParams}}{{#isBodyParam}}){{/isBodyParam}}{{/allParams}});
|
||||||
|
{{/reactive}}
|
@ -9,12 +9,15 @@ import springfox.documentation.service.ApiInfo;
|
|||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
{{#useOptional}}
|
{{#useOptional}}
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
{{/useOptional}}
|
{{/useOptional}}
|
||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
public class OpenAPIDocumentationConfig {
|
public class OpenAPIDocumentationConfig {
|
||||||
|
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#returnContainer}}{{#isMapContainer}}Map<String, {{{returnType}}}>{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
{{#isMapContainer}}{{#reactive}}Mono<{{/reactive}}Map<String, {{{returnType}}}{{#reactive}}>{{/reactive}}>{{/isMapContainer}}{{#isListContainer}}{{#reactive}}Flux{{/reactive}}{{^reactive}}List{{/reactive}}<{{{returnType}}}>{{/isListContainer}}{{^returnContainer}}{{#reactive}}Mono<{{{returnType}}}>{{/reactive}}{{^reactive}}{{{returnType}}}{{/reactive}}{{/returnContainer}}
|
12
pom.xml
12
pom.xml
@ -790,6 +790,18 @@
|
|||||||
<module>samples/server/petstore/springboot-beanvalidation</module>
|
<module>samples/server/petstore/springboot-beanvalidation</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>springboot-reactive</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>java</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/server/petstore/springboot-reactive</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>springboot</id>
|
<id>springboot</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<name>petstore-spring-cloud</name>
|
<name>petstore-spring-cloud</name>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.7</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.18</swagger-core-version>
|
<swagger-core-version>1.5.18</swagger-core-version>
|
||||||
@ -52,9 +52,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.joschi.jackson</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.6.4</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Bean Validation API support -->
|
<!-- Bean Validation API support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -9,8 +9,9 @@ import org.openapitools.model.ModelApiResponse;
|
|||||||
import org.openapitools.model.Pet;
|
import org.openapitools.model.Pet;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -18,11 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "Pet", description = "the Pet API")
|
@Api(value = "Pet", description = "the Pet API")
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
@ -124,7 +128,7 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
consumes = "application/x-www-form-urlencoded",
|
consumes = "application/x-www-form-urlencoded",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
com.netflix.hystrix.HystrixCommand<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" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status);
|
com.netflix.hystrix.HystrixCommand<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" , defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" , defaultValue="null") @RequestParam(value="status", required=false) String status);
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||||
@ -139,6 +143,6 @@ public interface PetApi {
|
|||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
consumes = "multipart/form-data",
|
consumes = "multipart/form-data",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file);
|
com.netflix.hystrix.HystrixCommand<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" , defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,8 +8,9 @@ package org.openapitools.api;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -17,11 +18,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "Store", description = "the Store API")
|
@Api(value = "Store", description = "the Store API")
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
@ -54,7 +58,7 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{orderId}",
|
@RequestMapping(value = "/store/order/{orderId}",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("orderId") Long orderId);
|
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @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", })
|
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,8 +8,9 @@ package org.openapitools.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -17,11 +18,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "User", description = "the User API")
|
@Api(value = "User", description = "the User API")
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
@ -1,232 +0,0 @@
|
|||||||
package org.openapitools.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.core.JsonTokenId;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
|
|
||||||
import org.threeten.bp.DateTimeException;
|
|
||||||
import org.threeten.bp.Instant;
|
|
||||||
import org.threeten.bp.OffsetDateTime;
|
|
||||||
import org.threeten.bp.ZoneId;
|
|
||||||
import org.threeten.bp.ZonedDateTime;
|
|
||||||
import org.threeten.bp.format.DateTimeFormatter;
|
|
||||||
import org.threeten.bp.temporal.Temporal;
|
|
||||||
import org.threeten.bp.temporal.TemporalAccessor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
|
|
||||||
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
|
|
||||||
*
|
|
||||||
* @author Nick Williams
|
|
||||||
*/
|
|
||||||
public class CustomInstantDeserializer<T extends Temporal>
|
|
||||||
extends ThreeTenDateTimeDeserializerBase<T> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
|
|
||||||
Instant.class, DateTimeFormatter.ISO_INSTANT,
|
|
||||||
new Function<TemporalAccessor, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return Instant.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(FromIntegerArguments a) {
|
|
||||||
return Instant.ofEpochMilli(a.value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(FromDecimalArguments a) {
|
|
||||||
return Instant.ofEpochSecond(a.integer, a.fraction);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
|
|
||||||
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
|
|
||||||
new Function<TemporalAccessor, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return OffsetDateTime.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(FromIntegerArguments a) {
|
|
||||||
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(FromDecimalArguments a) {
|
|
||||||
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
|
|
||||||
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
|
|
||||||
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
|
|
||||||
new Function<TemporalAccessor, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return ZonedDateTime.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(FromIntegerArguments a) {
|
|
||||||
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(FromDecimalArguments a) {
|
|
||||||
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
|
|
||||||
return zonedDateTime.withZoneSameInstant(zoneId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
protected final Function<FromIntegerArguments, T> fromMilliseconds;
|
|
||||||
|
|
||||||
protected final Function<FromDecimalArguments, T> fromNanoseconds;
|
|
||||||
|
|
||||||
protected final Function<TemporalAccessor, T> parsedToValue;
|
|
||||||
|
|
||||||
protected final BiFunction<T, ZoneId, T> adjust;
|
|
||||||
|
|
||||||
protected CustomInstantDeserializer(Class<T> supportedType,
|
|
||||||
DateTimeFormatter parser,
|
|
||||||
Function<TemporalAccessor, T> parsedToValue,
|
|
||||||
Function<FromIntegerArguments, T> fromMilliseconds,
|
|
||||||
Function<FromDecimalArguments, T> fromNanoseconds,
|
|
||||||
BiFunction<T, ZoneId, T> adjust) {
|
|
||||||
super(supportedType, parser);
|
|
||||||
this.parsedToValue = parsedToValue;
|
|
||||||
this.fromMilliseconds = fromMilliseconds;
|
|
||||||
this.fromNanoseconds = fromNanoseconds;
|
|
||||||
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
|
|
||||||
@Override
|
|
||||||
public T apply(T t, ZoneId zoneId) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
} : adjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
|
|
||||||
super((Class<T>) base.handledType(), f);
|
|
||||||
parsedToValue = base.parsedToValue;
|
|
||||||
fromMilliseconds = base.fromMilliseconds;
|
|
||||||
fromNanoseconds = base.fromNanoseconds;
|
|
||||||
adjust = base.adjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
|
|
||||||
if (dtf == _formatter) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return new CustomInstantDeserializer<T>(this, dtf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
|
||||||
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
|
|
||||||
//string values have to be adjusted to the configured TZ.
|
|
||||||
switch (parser.getCurrentTokenId()) {
|
|
||||||
case JsonTokenId.ID_NUMBER_FLOAT: {
|
|
||||||
BigDecimal value = parser.getDecimalValue();
|
|
||||||
long seconds = value.longValue();
|
|
||||||
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
|
|
||||||
return fromNanoseconds.apply(new FromDecimalArguments(
|
|
||||||
seconds, nanoseconds, getZone(context)));
|
|
||||||
}
|
|
||||||
|
|
||||||
case JsonTokenId.ID_NUMBER_INT: {
|
|
||||||
long timestamp = parser.getLongValue();
|
|
||||||
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
|
|
||||||
return this.fromNanoseconds.apply(new FromDecimalArguments(
|
|
||||||
timestamp, 0, this.getZone(context)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return this.fromMilliseconds.apply(new FromIntegerArguments(
|
|
||||||
timestamp, this.getZone(context)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
case JsonTokenId.ID_STRING: {
|
|
||||||
String string = parser.getText().trim();
|
|
||||||
if (string.length() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (string.endsWith("+0000")) {
|
|
||||||
string = string.substring(0, string.length() - 5) + "Z";
|
|
||||||
}
|
|
||||||
T value;
|
|
||||||
try {
|
|
||||||
TemporalAccessor acc = _formatter.parse(string);
|
|
||||||
value = parsedToValue.apply(acc);
|
|
||||||
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
|
|
||||||
return adjust.apply(value, this.getZone(context));
|
|
||||||
}
|
|
||||||
} catch (DateTimeException e) {
|
|
||||||
throw _peelDTE(e);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw context.mappingException("Expected type float, integer, or string.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private ZoneId getZone(DeserializationContext context) {
|
|
||||||
// Instants are always in UTC, so don't waste compute cycles
|
|
||||||
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FromIntegerArguments {
|
|
||||||
public final long value;
|
|
||||||
public final ZoneId zoneId;
|
|
||||||
|
|
||||||
private FromIntegerArguments(long value, ZoneId zoneId) {
|
|
||||||
this.value = value;
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FromDecimalArguments {
|
|
||||||
public final long integer;
|
|
||||||
public final int fraction;
|
|
||||||
public final ZoneId zoneId;
|
|
||||||
|
|
||||||
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
|
|
||||||
this.integer = integer;
|
|
||||||
this.fraction = fraction;
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package org.openapitools.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.threeten.bp.Instant;
|
|
||||||
import org.threeten.bp.OffsetDateTime;
|
|
||||||
import org.threeten.bp.ZonedDateTime;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class JacksonConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(ThreeTenModule.class)
|
|
||||||
ThreeTenModule threeTenModule() {
|
|
||||||
ThreeTenModule module = new ThreeTenModule();
|
|
||||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
|
||||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
|
||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.threeten.bp.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
@ -32,7 +32,7 @@ public class Pet {
|
|||||||
|
|
||||||
@JsonProperty("photoUrls")
|
@JsonProperty("photoUrls")
|
||||||
@Valid
|
@Valid
|
||||||
private List<String> photoUrls = new ArrayList<String>();
|
private List<String> photoUrls = new ArrayList<>();
|
||||||
|
|
||||||
@JsonProperty("tags")
|
@JsonProperty("tags")
|
||||||
@Valid
|
@Valid
|
||||||
@ -169,7 +169,7 @@ public class Pet {
|
|||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
if (this.tags == null) {
|
if (this.tags == null) {
|
||||||
this.tags = new ArrayList<Tag>();
|
this.tags = new ArrayList<>();
|
||||||
}
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
# Swagger generated API stub
|
# OpenAPI generated API stub
|
||||||
|
|
||||||
Spring Framework stub
|
Spring Framework stub
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project.
|
This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||||
By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate an API stub.
|
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub.
|
||||||
This is an example of building API stub interfaces in Java using the Spring framework.
|
This is an example of building API stub interfaces in Java using the Spring framework.
|
||||||
|
|
||||||
The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints
|
The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints
|
||||||
|
@ -6,15 +6,15 @@
|
|||||||
<name>spring-stubs</name>
|
<name>spring-stubs</name>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.7</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<springfox-version>2.7.0</springfox-version>
|
<springfox-version>2.8.0</springfox-version>
|
||||||
</properties>
|
</properties>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>2.0.1.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
@ -24,10 +24,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--SpringFox dependencies -->
|
<!--SpringFox dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
@ -41,9 +37,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.joschi.jackson</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.6.4</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Bean Validation API support -->
|
<!-- Bean Validation API support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -9,8 +9,9 @@ import org.openapitools.model.ModelApiResponse;
|
|||||||
import org.openapitools.model.Pet;
|
import org.openapitools.model.Pet;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -18,15 +19,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "pet", description = "the pet API")
|
@Api(value = "pet", description = "the pet API")
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
@ -38,7 +46,10 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet",
|
@RequestMapping(value = "/pet",
|
||||||
consumes = "application/json",
|
consumes = "application/json",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet);
|
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
|
||||||
@ -51,7 +62,10 @@ public interface PetApi {
|
|||||||
@ApiResponse(code = 400, message = "Invalid pet value") })
|
@ApiResponse(code = 400, message = "Invalid pet value") })
|
||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
method = RequestMethod.DELETE)
|
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);
|
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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@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 = {
|
@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 = {
|
||||||
@ -66,7 +80,22 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/findByStatus",
|
@RequestMapping(value = "/pet/findByStatus",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
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);
|
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) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@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 = {
|
@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 = {
|
||||||
@ -81,7 +110,22 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/findByTags",
|
@RequestMapping(value = "/pet/findByTags",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
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);
|
default ResponseEntity<List<Pet>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||||
@ -94,7 +138,22 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
|
default ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
|
||||||
@ -110,7 +169,10 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet",
|
@RequestMapping(value = "/pet",
|
||||||
consumes = "application/json",
|
consumes = "application/json",
|
||||||
method = RequestMethod.PUT)
|
method = RequestMethod.PUT)
|
||||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet);
|
default ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
|
||||||
@ -124,7 +186,10 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
consumes = "application/x-www-form-urlencoded",
|
consumes = "application/x-www-form-urlencoded",
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status);
|
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", defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) String status) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||||
@ -139,6 +204,17 @@ public interface PetApi {
|
|||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
consumes = "multipart/form-data",
|
consumes = "multipart/form-data",
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
|
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", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,8 +8,9 @@ package org.openapitools.api;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -17,22 +18,32 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "store", description = "the store API")
|
@Api(value = "store", description = "the store API")
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@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", })
|
@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 = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
@ApiResponse(code = 404, message = "Order not found") })
|
@ApiResponse(code = 404, message = "Order not found") })
|
||||||
@RequestMapping(value = "/store/order/{orderId}",
|
@RequestMapping(value = "/store/order/{orderId}",
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId);
|
default ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||||
@ -43,7 +54,10 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/inventory",
|
@RequestMapping(value = "/store/inventory",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Map<String, Integer>> getInventory();
|
default ResponseEntity<Map<String, Integer>> getInventory() {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@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", })
|
@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", })
|
||||||
@ -54,7 +68,22 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{orderId}",
|
@RequestMapping(value = "/store/order/{orderId}",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("orderId") Long orderId);
|
default ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||||
@ -64,6 +93,21 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order",
|
@RequestMapping(value = "/store/order",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order);
|
default ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,8 +8,9 @@ package org.openapitools.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -17,21 +18,31 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "user", description = "the user API")
|
@Api(value = "user", description = "the user API")
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user",
|
@RequestMapping(value = "/user",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user);
|
default ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
|
||||||
@ -39,7 +50,10 @@ public interface UserApi {
|
|||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user/createWithArray",
|
@RequestMapping(value = "/user/createWithArray",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user);
|
default ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
|
||||||
@ -47,7 +61,10 @@ public interface UserApi {
|
|||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user/createWithList",
|
@RequestMapping(value = "/user/createWithList",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user);
|
default ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||||
@ -56,7 +73,10 @@ public interface UserApi {
|
|||||||
@ApiResponse(code = 404, message = "User not found") })
|
@ApiResponse(code = 404, message = "User not found") })
|
||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
|
default ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", })
|
||||||
@ -67,7 +87,22 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
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);
|
default ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathVariable("username") String username) {
|
||||||
|
getRequest().ifPresent(request -> {
|
||||||
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
|
||||||
@ -77,7 +112,10 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/login",
|
@RequestMapping(value = "/user/login",
|
||||||
produces = "application/json",
|
produces = "application/json",
|
||||||
method = RequestMethod.GET)
|
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);
|
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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
|
||||||
@ -85,7 +123,10 @@ public interface UserApi {
|
|||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user/logout",
|
@RequestMapping(value = "/user/logout",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Void> logoutUser();
|
default ResponseEntity<Void> logoutUser() {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||||
@ -94,6 +135,9 @@ public interface UserApi {
|
|||||||
@ApiResponse(code = 404, message = "User not found") })
|
@ApiResponse(code = 404, message = "User not found") })
|
||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.PUT)
|
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 user);
|
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 user) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,232 +0,0 @@
|
|||||||
package org.openapitools.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.core.JsonTokenId;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
|
|
||||||
import org.threeten.bp.DateTimeException;
|
|
||||||
import org.threeten.bp.Instant;
|
|
||||||
import org.threeten.bp.OffsetDateTime;
|
|
||||||
import org.threeten.bp.ZoneId;
|
|
||||||
import org.threeten.bp.ZonedDateTime;
|
|
||||||
import org.threeten.bp.format.DateTimeFormatter;
|
|
||||||
import org.threeten.bp.temporal.Temporal;
|
|
||||||
import org.threeten.bp.temporal.TemporalAccessor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
|
|
||||||
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
|
|
||||||
*
|
|
||||||
* @author Nick Williams
|
|
||||||
*/
|
|
||||||
public class CustomInstantDeserializer<T extends Temporal>
|
|
||||||
extends ThreeTenDateTimeDeserializerBase<T> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
|
|
||||||
Instant.class, DateTimeFormatter.ISO_INSTANT,
|
|
||||||
new Function<TemporalAccessor, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return Instant.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(FromIntegerArguments a) {
|
|
||||||
return Instant.ofEpochMilli(a.value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, Instant>() {
|
|
||||||
@Override
|
|
||||||
public Instant apply(FromDecimalArguments a) {
|
|
||||||
return Instant.ofEpochSecond(a.integer, a.fraction);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
|
|
||||||
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
|
|
||||||
new Function<TemporalAccessor, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return OffsetDateTime.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(FromIntegerArguments a) {
|
|
||||||
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(FromDecimalArguments a) {
|
|
||||||
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
|
|
||||||
@Override
|
|
||||||
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
|
|
||||||
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
|
|
||||||
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
|
|
||||||
new Function<TemporalAccessor, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
|
|
||||||
return ZonedDateTime.from(temporalAccessor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromIntegerArguments, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(FromIntegerArguments a) {
|
|
||||||
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Function<FromDecimalArguments, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(FromDecimalArguments a) {
|
|
||||||
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
|
|
||||||
@Override
|
|
||||||
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
|
|
||||||
return zonedDateTime.withZoneSameInstant(zoneId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
protected final Function<FromIntegerArguments, T> fromMilliseconds;
|
|
||||||
|
|
||||||
protected final Function<FromDecimalArguments, T> fromNanoseconds;
|
|
||||||
|
|
||||||
protected final Function<TemporalAccessor, T> parsedToValue;
|
|
||||||
|
|
||||||
protected final BiFunction<T, ZoneId, T> adjust;
|
|
||||||
|
|
||||||
protected CustomInstantDeserializer(Class<T> supportedType,
|
|
||||||
DateTimeFormatter parser,
|
|
||||||
Function<TemporalAccessor, T> parsedToValue,
|
|
||||||
Function<FromIntegerArguments, T> fromMilliseconds,
|
|
||||||
Function<FromDecimalArguments, T> fromNanoseconds,
|
|
||||||
BiFunction<T, ZoneId, T> adjust) {
|
|
||||||
super(supportedType, parser);
|
|
||||||
this.parsedToValue = parsedToValue;
|
|
||||||
this.fromMilliseconds = fromMilliseconds;
|
|
||||||
this.fromNanoseconds = fromNanoseconds;
|
|
||||||
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
|
|
||||||
@Override
|
|
||||||
public T apply(T t, ZoneId zoneId) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
} : adjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
|
|
||||||
super((Class<T>) base.handledType(), f);
|
|
||||||
parsedToValue = base.parsedToValue;
|
|
||||||
fromMilliseconds = base.fromMilliseconds;
|
|
||||||
fromNanoseconds = base.fromNanoseconds;
|
|
||||||
adjust = base.adjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
|
|
||||||
if (dtf == _formatter) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return new CustomInstantDeserializer<T>(this, dtf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
|
||||||
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
|
|
||||||
//string values have to be adjusted to the configured TZ.
|
|
||||||
switch (parser.getCurrentTokenId()) {
|
|
||||||
case JsonTokenId.ID_NUMBER_FLOAT: {
|
|
||||||
BigDecimal value = parser.getDecimalValue();
|
|
||||||
long seconds = value.longValue();
|
|
||||||
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
|
|
||||||
return fromNanoseconds.apply(new FromDecimalArguments(
|
|
||||||
seconds, nanoseconds, getZone(context)));
|
|
||||||
}
|
|
||||||
|
|
||||||
case JsonTokenId.ID_NUMBER_INT: {
|
|
||||||
long timestamp = parser.getLongValue();
|
|
||||||
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
|
|
||||||
return this.fromNanoseconds.apply(new FromDecimalArguments(
|
|
||||||
timestamp, 0, this.getZone(context)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return this.fromMilliseconds.apply(new FromIntegerArguments(
|
|
||||||
timestamp, this.getZone(context)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
case JsonTokenId.ID_STRING: {
|
|
||||||
String string = parser.getText().trim();
|
|
||||||
if (string.length() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (string.endsWith("+0000")) {
|
|
||||||
string = string.substring(0, string.length() - 5) + "Z";
|
|
||||||
}
|
|
||||||
T value;
|
|
||||||
try {
|
|
||||||
TemporalAccessor acc = _formatter.parse(string);
|
|
||||||
value = parsedToValue.apply(acc);
|
|
||||||
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
|
|
||||||
return adjust.apply(value, this.getZone(context));
|
|
||||||
}
|
|
||||||
} catch (DateTimeException e) {
|
|
||||||
throw _peelDTE(e);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw context.mappingException("Expected type float, integer, or string.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private ZoneId getZone(DeserializationContext context) {
|
|
||||||
// Instants are always in UTC, so don't waste compute cycles
|
|
||||||
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FromIntegerArguments {
|
|
||||||
public final long value;
|
|
||||||
public final ZoneId zoneId;
|
|
||||||
|
|
||||||
private FromIntegerArguments(long value, ZoneId zoneId) {
|
|
||||||
this.value = value;
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FromDecimalArguments {
|
|
||||||
public final long integer;
|
|
||||||
public final int fraction;
|
|
||||||
public final ZoneId zoneId;
|
|
||||||
|
|
||||||
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
|
|
||||||
this.integer = integer;
|
|
||||||
this.fraction = fraction;
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package org.openapitools.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.threeten.bp.Instant;
|
|
||||||
import org.threeten.bp.OffsetDateTime;
|
|
||||||
import org.threeten.bp.ZonedDateTime;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class JacksonConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(ThreeTenModule.class)
|
|
||||||
ThreeTenModule threeTenModule() {
|
|
||||||
ThreeTenModule module = new ThreeTenModule();
|
|
||||||
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
|
|
||||||
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
|
|
||||||
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.threeten.bp.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
@ -32,7 +32,7 @@ public class Pet {
|
|||||||
|
|
||||||
@JsonProperty("photoUrls")
|
@JsonProperty("photoUrls")
|
||||||
@Valid
|
@Valid
|
||||||
private List<String> photoUrls = new ArrayList<String>();
|
private List<String> photoUrls = new ArrayList<>();
|
||||||
|
|
||||||
@JsonProperty("tags")
|
@JsonProperty("tags")
|
||||||
@Valid
|
@Valid
|
||||||
@ -169,7 +169,7 @@ public class Pet {
|
|||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
if (this.tags == null) {
|
if (this.tags == null) {
|
||||||
this.tags = new ArrayList<Tag>();
|
this.tags = new ArrayList<>();
|
||||||
}
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
|
@ -1 +1 @@
|
|||||||
2.4.0-SNAPSHOT
|
3.0.0-SNAPSHOT
|
@ -1 +1 @@
|
|||||||
2.4.0-SNAPSHOT
|
3.0.0-SNAPSHOT
|
@ -0,0 +1 @@
|
|||||||
|
3.0.0-SNAPSHOT
|
@ -1,12 +1,12 @@
|
|||||||
# Swagger generated server
|
# OpenAPI generated server
|
||||||
|
|
||||||
Spring MVC Server
|
Spring MVC Server
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework.
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the Spring MVC framework.
|
||||||
|
|
||||||
The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
The underlying library integrating OpenAPI to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
||||||
|
|
||||||
You can view the server in swagger-ui by pointing to
|
You can view the server in swagger-ui by pointing to
|
||||||
http://localhost:8002/v2/swagger-ui.html
|
http://localhost:8002/v2/swagger-ui.html
|
@ -1,18 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -20,33 +17,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "another-fake", description = "the another-fake API")
|
@Api(value = "another-fake", description = "the another-fake API")
|
||||||
public interface AnotherFakeApi {
|
public interface AnotherFakeApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(AnotherFakeApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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?", })
|
@ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||||
@ -55,11 +42,18 @@ public interface AnotherFakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default CompletableFuture<ResponseEntity<Client>> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default CompletableFuture<ResponseEntity<Client>> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public AnotherFakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -13,13 +13,10 @@ import java.time.OffsetDateTime;
|
|||||||
import org.openapitools.model.OuterComposite;
|
import org.openapitools.model.OuterComposite;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -27,45 +24,42 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "fake", description = "the fake API")
|
@Api(value = "fake", description = "the fake API")
|
||||||
public interface FakeApi {
|
public interface FakeApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(FakeApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||||
@RequestMapping(value = "/fake/outer/boolean",
|
@RequestMapping(value = "/fake/outer/boolean",
|
||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Boolean>> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean booleanPostBody) {
|
default CompletableFuture<ResponseEntity<Boolean>> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,11 +70,18 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<OuterComposite>> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
default CompletableFuture<ResponseEntity<OuterComposite>> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "*/*", "{ }");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,11 +92,18 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<BigDecimal>> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
default CompletableFuture<ResponseEntity<BigDecimal>> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,11 +114,18 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<String>> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
default CompletableFuture<ResponseEntity<String>> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,11 +136,8 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PUT)
|
method = RequestMethod.PUT)
|
||||||
default CompletableFuture<ResponseEntity<Void>> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
default CompletableFuture<ResponseEntity<Void>> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,11 +149,18 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default CompletableFuture<ResponseEntity<Client>> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default CompletableFuture<ResponseEntity<Client>> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,12 +173,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Void>> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", allowableValues="") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", allowableValues="") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None") @RequestParam(value="callback", required=false) String paramCallback) {
|
default CompletableFuture<ResponseEntity<Void>> testEndpointParameters(@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None", defaultValue="null") @RequestParam(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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,12 +186,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Void>> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
default CompletableFuture<ResponseEntity<Void>> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="new ArrayList<>()") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -186,11 +199,8 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Void>> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
default CompletableFuture<ResponseEntity<Void>> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -200,12 +210,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake/jsonFormData",
|
@RequestMapping(value = "/fake/jsonFormData",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Void>> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestParam(value="param2", required=true) String param2) {
|
default CompletableFuture<ResponseEntity<Void>> testJsonFormData(@ApiParam(value = "field1", required=true, defaultValue="null") @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true, defaultValue="null") @RequestParam(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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeApiController implements FakeApi {
|
public class FakeApiController implements FakeApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -20,33 +17,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||||
public interface FakeClassnameTestApi {
|
public interface FakeClassnameTestApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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 = "To test class name in snake case", response = Client.class, authorizations = {
|
@ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = {
|
||||||
@Authorization(value = "api_key_query")
|
@Authorization(value = "api_key_query")
|
||||||
}, tags={ "fake_classname_tags 123#$%^", })
|
}, tags={ "fake_classname_tags 123#$%^", })
|
||||||
@ -57,11 +44,18 @@ public interface FakeClassnameTestApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default CompletableFuture<ResponseEntity<Client>> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default CompletableFuture<ResponseEntity<Client>> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeClassnameTestApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,13 +8,10 @@ package org.openapitools.api;
|
|||||||
import org.openapitools.model.ModelApiResponse;
|
import org.openapitools.model.ModelApiResponse;
|
||||||
import org.openapitools.model.Pet;
|
import org.openapitools.model.Pet;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -22,33 +19,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "pet", description = "the pet API")
|
@Api(value = "pet", description = "the pet API")
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(PetApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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 = {
|
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
@ -61,11 +48,8 @@ public interface PetApi {
|
|||||||
consumes = { "application/json", "application/xml" },
|
consumes = { "application/json", "application/xml" },
|
||||||
method = RequestMethod.POST)
|
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 pet) {
|
default CompletableFuture<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,11 +64,8 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
method = RequestMethod.DELETE)
|
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) {
|
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,11 +82,22 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,11 +114,22 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,11 +144,22 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
default CompletableFuture<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,11 +177,8 @@ public interface PetApi {
|
|||||||
consumes = { "application/json", "application/xml" },
|
consumes = { "application/json", "application/xml" },
|
||||||
method = RequestMethod.PUT)
|
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 pet) {
|
default CompletableFuture<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,12 +193,9 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status) {
|
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", defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,12 +211,19 @@ public interface PetApi {
|
|||||||
produces = { "application/json" },
|
produces = { "application/json" },
|
||||||
consumes = { "multipart/form-data" },
|
consumes = { "multipart/form-data" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
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", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class PetApiController implements PetApi {
|
public class PetApiController implements PetApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public PetApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,33 +18,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "store", description = "the store API")
|
@Api(value = "store", description = "the store API")
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(StoreApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@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 = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
@ -55,11 +42,8 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{order_id}",
|
@RequestMapping(value = "/store/order/{order_id}",
|
||||||
method = RequestMethod.DELETE)
|
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) {
|
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -72,11 +56,8 @@ public interface StoreApi {
|
|||||||
produces = { "application/json" },
|
produces = { "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Map<String, Integer>>> getInventory() {
|
default CompletableFuture<ResponseEntity<Map<String, Integer>>> getInventory() {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,12 +69,23 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{order_id}",
|
@RequestMapping(value = "/store/order/{order_id}",
|
||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("order_id") Long orderId) {
|
default CompletableFuture<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,11 +97,22 @@ public interface StoreApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
default CompletableFuture<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class StoreApiController implements StoreApi {
|
public class StoreApiController implements StoreApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public StoreApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,44 +18,31 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Api(value = "user", description = "the user API")
|
@Api(value = "user", description = "the user API")
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(UserApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user",
|
@RequestMapping(value = "/user",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
default CompletableFuture<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,11 +52,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/createWithArray",
|
@RequestMapping(value = "/user/createWithArray",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
default CompletableFuture<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,11 +63,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/createWithList",
|
@RequestMapping(value = "/user/createWithList",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default CompletableFuture<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
default CompletableFuture<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,11 +75,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
default CompletableFuture<ResponseEntity<Void>> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,11 +89,22 @@ public interface UserApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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()) {
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
} else {
|
getRequest().ifPresent(request -> {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
}
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}, Runnable::run);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -130,11 +116,8 @@ public interface UserApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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()) {
|
|
||||||
} 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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,11 +127,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/logout",
|
@RequestMapping(value = "/user/logout",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default CompletableFuture<ResponseEntity<Void>> logoutUser() {
|
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,11 +139,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.PUT)
|
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 user) {
|
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 user) {
|
||||||
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));
|
return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UserApiController implements UserApi {
|
public class UserApiController implements UserApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public UserApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,12 @@ import springfox.documentation.service.ApiInfo;
|
|||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SwaggerDocumentationConfig {
|
@EnableSwagger2
|
||||||
|
public class OpenAPIDocumentationConfig {
|
||||||
|
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
@ -0,0 +1,79 @@
|
|||||||
|
package org.openapitools.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan(basePackages = "org.openapitools.api")
|
||||||
|
@EnableWebMvc
|
||||||
|
@PropertySource("classpath:swagger.properties")
|
||||||
|
@Import(OpenAPIDocumentationConfig.class)
|
||||||
|
public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||||
|
|
||||||
|
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
|
||||||
|
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||||
|
"classpath:/static/", "classpath:/public/" };
|
||||||
|
|
||||||
|
private static final String[] RESOURCE_LOCATIONS;
|
||||||
|
static {
|
||||||
|
RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length
|
||||||
|
+ SERVLET_RESOURCE_LOCATIONS.length];
|
||||||
|
System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0,
|
||||||
|
SERVLET_RESOURCE_LOCATIONS.length);
|
||||||
|
System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS,
|
||||||
|
SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String[] STATIC_INDEX_HTML_RESOURCES;
|
||||||
|
static {
|
||||||
|
STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length];
|
||||||
|
for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) {
|
||||||
|
STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
if (!registry.hasMappingForPattern("/webjars/**")) {
|
||||||
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||||
|
}
|
||||||
|
if (!registry.hasMappingForPattern("/**")) {
|
||||||
|
registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilder builder() {
|
||||||
|
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder()
|
||||||
|
.indentOutput(true)
|
||||||
|
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||||
|
.dateFormat(new RFC3339DateFormat());
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
|
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
||||||
|
super.configureMessageConverters(converters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper(){
|
||||||
|
return builder().build();
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,11 @@ import springfox.documentation.service.ApiInfo;
|
|||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
public class SwaggerDocumentationConfig {
|
public class SwaggerDocumentationConfig {
|
||||||
|
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
|
@ -13,7 +13,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
|||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = "org.openapitools.api")
|
@ComponentScan(basePackages = "org.openapitools.api")
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
|
||||||
@PropertySource("classpath:swagger.properties")
|
@PropertySource("classpath:swagger.properties")
|
||||||
@Import(SwaggerDocumentationConfig.class)
|
@Import(SwaggerDocumentationConfig.class)
|
||||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
@ -7,7 +7,7 @@ public class WebApplication extends AbstractAnnotationConfigDispatcherServletIni
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getRootConfigClasses() {
|
protected Class<?>[] getRootConfigClasses() {
|
||||||
return new Class[] { SwaggerUiConfiguration.class };
|
return new Class[] { OpenAPIUiConfiguration.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.openapitools.model.Animal;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AnimalFarm
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
|
||||||
|
public class AnimalFarm extends ArrayList<Animal> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(java.lang.Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class AnimalFarm {\n");
|
||||||
|
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(java.lang.Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
# Swagger generated server
|
# OpenAPI generated server
|
||||||
|
|
||||||
Spring MVC Server
|
Spring MVC Server
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework.
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the Spring MVC framework.
|
||||||
|
|
||||||
The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
The underlying library integrating OpenAPI to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
||||||
|
|
||||||
You can view the server in swagger-ui by pointing to
|
You can view the server in swagger-ui by pointing to
|
||||||
http://localhost:8002/v2/swagger-ui.html
|
http://localhost:8002/v2/swagger-ui.html
|
@ -1,18 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -20,32 +17,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "another-fake", description = "the another-fake API")
|
@Api(value = "another-fake", description = "the another-fake API")
|
||||||
public interface AnotherFakeApi {
|
public interface AnotherFakeApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(AnotherFakeApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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?", })
|
@ApiOperation(value = "To test special tags", nickname = "testSpecialTags", notes = "To test special tags", response = Client.class, tags={ "$another-fake?", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||||
@ -54,11 +41,16 @@ public interface AnotherFakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default AnotherFakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public AnotherFakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -13,13 +13,10 @@ import java.util.Map;
|
|||||||
import org.openapitools.model.OuterComposite;
|
import org.openapitools.model.OuterComposite;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -27,44 +24,39 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "fake", description = "the fake API")
|
@Api(value = "fake", description = "the fake API")
|
||||||
public interface FakeApi {
|
public interface FakeApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(FakeApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@ApiOperation(value = "", nickname = "fakeOuterBooleanSerialize", notes = "Test serialization of outer boolean types", response = Boolean.class, tags={ "fake", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
@ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) })
|
||||||
@RequestMapping(value = "/fake/outer/boolean",
|
@RequestMapping(value = "/fake/outer/boolean",
|
||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean booleanPostBody) {
|
default ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,11 +67,16 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
default ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "*/*", "{ }");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,11 +87,16 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
default ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,11 +107,16 @@ public interface FakeApi {
|
|||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
default ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,11 +127,8 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PUT)
|
method = RequestMethod.PUT)
|
||||||
default ResponseEntity<Void> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
default ResponseEntity<Void> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,11 +140,16 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,12 +162,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", allowableValues="") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", allowableValues="") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestParam(value="dateTime", required=false) LocalDateTime dateTime,@ApiParam(value = "None") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None") @RequestParam(value="callback", required=false) String paramCallback) {
|
default ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="dateTime", required=false) LocalDateTime dateTime,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None", defaultValue="null") @RequestParam(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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,12 +175,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
default ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="new ArrayList<>()") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -185,11 +188,8 @@ public interface FakeApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
default ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -199,12 +199,9 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake/jsonFormData",
|
@RequestMapping(value = "/fake/jsonFormData",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestParam(value="param2", required=true) String param2) {
|
default ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true, defaultValue="null") @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true, defaultValue="null") @RequestParam(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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeApiController implements FakeApi {
|
public class FakeApiController implements FakeApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -20,32 +17,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||||
public interface FakeClassnameTestApi {
|
public interface FakeClassnameTestApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(FakeClassnameTestApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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 = "To test class name in snake case", response = Client.class, authorizations = {
|
@ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = {
|
||||||
@Authorization(value = "api_key_query")
|
@Authorization(value = "api_key_query")
|
||||||
}, tags={ "fake_classname_tags 123#$%^", })
|
}, tags={ "fake_classname_tags 123#$%^", })
|
||||||
@ -56,11 +43,16 @@ public interface FakeClassnameTestApi {
|
|||||||
consumes = { "application/json" },
|
consumes = { "application/json" },
|
||||||
method = RequestMethod.PATCH)
|
method = RequestMethod.PATCH)
|
||||||
default ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
default ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default FakeClassnameTestApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeClassnameTestApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,13 +8,10 @@ package org.openapitools.api;
|
|||||||
import org.openapitools.model.ModelApiResponse;
|
import org.openapitools.model.ModelApiResponse;
|
||||||
import org.openapitools.model.Pet;
|
import org.openapitools.model.Pet;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -22,32 +19,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "pet", description = "the pet API")
|
@Api(value = "pet", description = "the pet API")
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(PetApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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 = {
|
@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
|
||||||
@Authorization(value = "petstore_auth", scopes = {
|
@Authorization(value = "petstore_auth", scopes = {
|
||||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||||
@ -60,11 +47,8 @@ public interface PetApi {
|
|||||||
consumes = { "application/json", "application/xml" },
|
consumes = { "application/json", "application/xml" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,11 +63,8 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
method = RequestMethod.DELETE)
|
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) {
|
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) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,11 +81,20 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,11 +111,20 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
default 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()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -140,11 +139,20 @@ public interface PetApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
default ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,11 +170,8 @@ public interface PetApi {
|
|||||||
consumes = { "application/json", "application/xml" },
|
consumes = { "application/json", "application/xml" },
|
||||||
method = RequestMethod.PUT)
|
method = RequestMethod.PUT)
|
||||||
default ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
default ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -181,12 +186,9 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status) {
|
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", defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,12 +204,17 @@ public interface PetApi {
|
|||||||
produces = { "application/json" },
|
produces = { "application/json" },
|
||||||
consumes = { "multipart/form-data" },
|
consumes = { "multipart/form-data" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
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", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class PetApiController implements PetApi {
|
public class PetApiController implements PetApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public PetApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,32 +18,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "store", description = "the store API")
|
@Api(value = "store", description = "the store API")
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(StoreApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@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 = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||||
@ -54,11 +41,8 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{order_id}",
|
@RequestMapping(value = "/store/order/{order_id}",
|
||||||
method = RequestMethod.DELETE)
|
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) {
|
default 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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,11 +55,8 @@ public interface StoreApi {
|
|||||||
produces = { "application/json" },
|
produces = { "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Map<String, Integer>> getInventory() {
|
default ResponseEntity<Map<String, Integer>> getInventory() {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,12 +68,21 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{order_id}",
|
@RequestMapping(value = "/store/order/{order_id}",
|
||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("order_id") Long orderId) {
|
default ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -104,11 +94,20 @@ public interface StoreApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
default ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
||||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class StoreApiController implements StoreApi {
|
public class StoreApiController implements StoreApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public StoreApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,43 +18,30 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Api(value = "user", description = "the user API")
|
@Api(value = "user", description = "the user API")
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
Logger log = LoggerFactory.getLogger(UserApi.class);
|
default Optional<NativeWebRequest> getRequest() {
|
||||||
|
|
||||||
default Optional<ObjectMapper> getObjectMapper() {
|
|
||||||
return Optional.empty();
|
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", })
|
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", tags={ "user", })
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "successful operation") })
|
@ApiResponse(code = 200, message = "successful operation") })
|
||||||
@RequestMapping(value = "/user",
|
@RequestMapping(value = "/user",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
default ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,11 +51,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/createWithArray",
|
@RequestMapping(value = "/user/createWithArray",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
default ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,11 +62,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/createWithList",
|
@RequestMapping(value = "/user/createWithList",
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
default ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
default ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,11 +74,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
default ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
|
default 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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,11 +88,20 @@ public interface UserApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
default 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()) {
|
getRequest().ifPresent(request -> {
|
||||||
} else {
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated");
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
}
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,11 +113,8 @@ public interface UserApi {
|
|||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
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) {
|
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) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -143,11 +124,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/logout",
|
@RequestMapping(value = "/user/logout",
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Void> logoutUser() {
|
default 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 new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,11 +136,8 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/user/{username}",
|
@RequestMapping(value = "/user/{username}",
|
||||||
method = RequestMethod.PUT)
|
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 user) {
|
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 user) {
|
||||||
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);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UserApiController implements UserApi {
|
public class UserApiController implements UserApi {
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public UserApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<NativeWebRequest> getRequest() {
|
||||||
return Optional.ofNullable(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<HttpServletRequest> getRequest() {
|
|
||||||
return Optional.ofNullable(request);
|
return Optional.ofNullable(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package org.openapitools.configuration;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class OpenAPIDocumentationConfig {
|
||||||
|
|
||||||
|
ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("Swagger Petstore")
|
||||||
|
.description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\")
|
||||||
|
.license("Apache-2.0")
|
||||||
|
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
|
||||||
|
.termsOfServiceUrl("")
|
||||||
|
.version("1.0.0")
|
||||||
|
.contact(new Contact("","", "apiteam@swagger.io"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket customImplementation(){
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("org.openapitools.api"))
|
||||||
|
.build()
|
||||||
|
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
|
||||||
|
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
|
||||||
|
.apiInfo(apiInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package org.openapitools.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan(basePackages = "org.openapitools.api")
|
||||||
|
@EnableWebMvc
|
||||||
|
@PropertySource("classpath:swagger.properties")
|
||||||
|
@Import(OpenAPIDocumentationConfig.class)
|
||||||
|
public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||||
|
|
||||||
|
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
|
||||||
|
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||||
|
"classpath:/static/", "classpath:/public/" };
|
||||||
|
|
||||||
|
private static final String[] RESOURCE_LOCATIONS;
|
||||||
|
static {
|
||||||
|
RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length
|
||||||
|
+ SERVLET_RESOURCE_LOCATIONS.length];
|
||||||
|
System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0,
|
||||||
|
SERVLET_RESOURCE_LOCATIONS.length);
|
||||||
|
System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS,
|
||||||
|
SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String[] STATIC_INDEX_HTML_RESOURCES;
|
||||||
|
static {
|
||||||
|
STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length];
|
||||||
|
for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) {
|
||||||
|
STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
if (!registry.hasMappingForPattern("/webjars/**")) {
|
||||||
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||||
|
}
|
||||||
|
if (!registry.hasMappingForPattern("/**")) {
|
||||||
|
registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilder builder() {
|
||||||
|
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder()
|
||||||
|
.indentOutput(true)
|
||||||
|
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||||
|
.dateFormat(new RFC3339DateFormat());
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
|
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
||||||
|
super.configureMessageConverters(converters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper(){
|
||||||
|
return builder().build();
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,11 @@ import springfox.documentation.service.ApiInfo;
|
|||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
public class SwaggerDocumentationConfig {
|
public class SwaggerDocumentationConfig {
|
||||||
|
|
||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
|
@ -13,7 +13,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
|||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = "org.openapitools.api")
|
@ComponentScan(basePackages = "org.openapitools.api")
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
|
||||||
@PropertySource("classpath:swagger.properties")
|
@PropertySource("classpath:swagger.properties")
|
||||||
@Import(SwaggerDocumentationConfig.class)
|
@Import(SwaggerDocumentationConfig.class)
|
||||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
@ -7,7 +7,7 @@ public class WebApplication extends AbstractAnnotationConfigDispatcherServletIni
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getRootConfigClasses() {
|
protected Class<?>[] getRootConfigClasses() {
|
||||||
return new Class[] { SwaggerUiConfiguration.class };
|
return new Class[] { OpenAPIUiConfiguration.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package org.openapitools.model;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.openapitools.model.Animal;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AnimalFarm
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
|
||||||
|
public class AnimalFarm extends ArrayList<Animal> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(java.lang.Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class AnimalFarm {\n");
|
||||||
|
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given object to string with each line indented by 4 spaces
|
||||||
|
* (except the first line).
|
||||||
|
*/
|
||||||
|
private String toIndentedString(java.lang.Object o) {
|
||||||
|
if (o == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return o.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
3.0.0-SNAPSHOT
|
@ -1,12 +1,12 @@
|
|||||||
# Swagger generated server
|
# OpenAPI generated server
|
||||||
|
|
||||||
Spring MVC Server
|
Spring MVC Server
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework.
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the Spring MVC framework.
|
||||||
|
|
||||||
The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
The underlying library integrating OpenAPI to Spring-MVC is [springfox](https://github.com/springfox/springfox)
|
||||||
|
|
||||||
You can view the server in swagger-ui by pointing to
|
You can view the server in swagger-ui by pointing to
|
||||||
http://localhost:8002/v2/swagger-ui.html
|
http://localhost:8002/v2/swagger-ui.html
|
@ -106,6 +106,12 @@
|
|||||||
<version>${springfox-version}</version>
|
<version>${springfox-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.joschi.jackson</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-datatype-threetenbp</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
@ -132,7 +138,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.7</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<jetty-version>9.2.15.v20160210</jetty-version>
|
<jetty-version>9.2.15.v20160210</jetty-version>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,7 +8,6 @@ package org.openapitools.api;
|
|||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "another-fake", description = "the another-fake API")
|
@Api(value = "another-fake", description = "the another-fake API")
|
||||||
public interface AnotherFakeApi {
|
public interface AnotherFakeApi {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -13,32 +11,33 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class AnotherFakeApiController implements AnotherFakeApi {
|
public class AnotherFakeApiController implements AnotherFakeApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AnotherFakeApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public AnotherFakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public AnotherFakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
public ResponseEntity<Client> testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.openapitools.api;
|
||||||
|
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiUtil {
|
||||||
|
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||||
|
try {
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType);
|
||||||
|
req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -15,7 +15,6 @@ import org.springframework.core.io.Resource;
|
|||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -28,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "fake", description = "the fake API")
|
@Api(value = "fake", description = "the fake API")
|
||||||
public interface FakeApi {
|
public interface FakeApi {
|
||||||
@ -38,7 +38,7 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake/outer/boolean",
|
@RequestMapping(value = "/fake/outer/boolean",
|
||||||
produces = { "*/*" },
|
produces = { "*/*" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean booleanPostBody);
|
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", })
|
@ApiOperation(value = "", nickname = "fakeOuterCompositeSerialize", notes = "Test serialization of object with outer number type", response = OuterComposite.class, tags={ "fake", })
|
||||||
@ -96,7 +96,7 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", allowableValues="") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", allowableValues="") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None") @RequestParam(value="callback", required=false) String paramCallback);
|
ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="callback", required=false) String paramCallback);
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
@ApiOperation(value = "To test enum parameters", nickname = "testEnumParameters", notes = "To test enum parameters", tags={ "fake", })
|
||||||
@ -106,7 +106,7 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake",
|
@RequestMapping(value = "/fake",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)") @RequestParam(value="enum_form_string", required=false) String enumFormString);
|
ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="new ArrayList<EnumFormStringArrayEnum>()") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestParam(value="enum_form_string", required=false) String enumFormString);
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
@ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", })
|
||||||
@ -124,6 +124,6 @@ public interface FakeApi {
|
|||||||
@RequestMapping(value = "/fake/jsonFormData",
|
@RequestMapping(value = "/fake/jsonFormData",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestParam(value="param2", required=true) String param2);
|
ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true, defaultValue="null") @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true, defaultValue="null") @RequestParam(value="param2", required=true) String param2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,9 @@ import org.threeten.bp.OffsetDateTime;
|
|||||||
import org.openapitools.model.OuterComposite;
|
import org.openapitools.model.OuterComposite;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -20,77 +18,102 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeApiController implements FakeApi {
|
public class FakeApiController implements FakeApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(FakeApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean booleanPostBody) {
|
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Boolean>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite outerComposite) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<OuterComposite>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "*/*", "{ }");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<BigDecimal>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "*/*", "null");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
public ResponseEntity<Void> testBodyWithQueryParams(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "query", required = true) String query,@ApiParam(value = "" ,required=true ) @Valid @RequestBody User user) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", allowableValues="") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", allowableValues="") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None") @RequestParam(value="callback", required=false) String paramCallback) {
|
public ResponseEntity<Void> testEndpointParameters(@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="double", required=true) Double _double,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true, defaultValue="null") @RequestParam(value="byte", required=true) byte[] _byte,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="integer", required=false) Integer integer,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int32", required=false) Integer int32,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="int64", required=false) Long int64,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="float", required=false) Float _float,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="string", required=false) String string,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile binary,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="date", required=false) LocalDate date,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="password", required=false) String password,@ApiParam(value = "None", defaultValue="null") @RequestParam(value="callback", required=false) String paramCallback) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
public ResponseEntity<Void> testEnumParameters(@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") @Valid @RequestParam(value = "enum_query_double", required = false) Double enumQueryDouble,@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $", defaultValue="new ArrayList<EnumFormStringArrayEnum>()") @RequestParam(value="enum_form_string_array", required=false) List<String> enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestParam(value="enum_form_string", required=false) String enumFormString) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
public ResponseEntity<Void> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody String requestBody) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true) @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true) @RequestParam(value="param2", required=true) String param2) {
|
public ResponseEntity<Void> testJsonFormData(@ApiParam(value = "field1", required=true, defaultValue="null") @RequestParam(value="param", required=true) String param,@ApiParam(value = "field2", required=true, defaultValue="null") @RequestParam(value="param2", required=true) String param2) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -8,7 +8,6 @@ package org.openapitools.api;
|
|||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -21,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||||
public interface FakeClassnameTestApi {
|
public interface FakeClassnameTestApi {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
|
|
||||||
import org.openapitools.model.Client;
|
import org.openapitools.model.Client;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -13,32 +11,33 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(FakeClassnameTestApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public FakeClassnameTestApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public FakeClassnameTestApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
public ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client client) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Client>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"client\" : \"client\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -10,7 +10,6 @@ import org.openapitools.model.Pet;
|
|||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -23,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "pet", description = "the pet API")
|
@Api(value = "pet", description = "the pet API")
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
@ -124,7 +124,7 @@ public interface PetApi {
|
|||||||
@RequestMapping(value = "/pet/{petId}",
|
@RequestMapping(value = "/pet/{petId}",
|
||||||
consumes = { "application/x-www-form-urlencoded" },
|
consumes = { "application/x-www-form-urlencoded" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status);
|
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", defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) String status);
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||||
@ -139,6 +139,6 @@ public interface PetApi {
|
|||||||
produces = { "application/json" },
|
produces = { "application/json" },
|
||||||
consumes = { "multipart/form-data" },
|
consumes = { "multipart/form-data" },
|
||||||
method = RequestMethod.POST)
|
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") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
|
ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,9 @@ package org.openapitools.api;
|
|||||||
import org.openapitools.model.ModelApiResponse;
|
import org.openapitools.model.ModelApiResponse;
|
||||||
import org.openapitools.model.Pet;
|
import org.openapitools.model.Pet;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -15,67 +13,98 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class PetApiController implements PetApi {
|
public class PetApiController implements PetApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PetApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public PetApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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) {
|
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<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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) {
|
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");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(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) {
|
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");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<List<Pet>>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Pet>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status></Pet>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) String status) {
|
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", defaultValue="null") @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) String status) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
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", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -22,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "store", description = "the store API")
|
@Api(value = "store", description = "the store API")
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
@ -54,7 +54,7 @@ public interface StoreApi {
|
|||||||
@RequestMapping(value = "/store/order/{order_id}",
|
@RequestMapping(value = "/store/order/{order_id}",
|
||||||
produces = { "application/xml", "application/json" },
|
produces = { "application/xml", "application/json" },
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("order_id") Long orderId);
|
ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @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", })
|
@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
|
||||||
|
@ -2,11 +2,9 @@ package org.openapitools.api;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openapitools.model.Order;
|
import org.openapitools.model.Order;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -14,47 +12,62 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class StoreApiController implements StoreApi {
|
public class StoreApiController implements StoreApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(StoreApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public StoreApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
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) {
|
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<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Map<String, Integer>> getInventory() {
|
public ResponseEntity<Map<String, Integer>> getInventory() {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("order_id") Long orderId) {
|
public ResponseEntity<Order> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order) {
|
||||||
String accept = request.getHeader("Accept");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<Order>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0-SNAPSHOT).
|
||||||
* https://github.com/swagger-api/swagger-codegen
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
package org.openapitools.api;
|
package org.openapitools.api;
|
||||||
@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
@ -22,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Api(value = "user", description = "the user API")
|
@Api(value = "user", description = "the user API")
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
@ -2,11 +2,9 @@ package org.openapitools.api;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openapitools.model.User;
|
import org.openapitools.model.User;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -14,67 +12,72 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UserApiController implements UserApi {
|
public class UserApiController implements UserApi {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
private final NativeWebRequest request;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) {
|
public UserApiController(NativeWebRequest request) {
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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) {
|
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<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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) {
|
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");
|
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED);
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||||
|
ApiUtil.setExampleResponse(request, "application/xml", "<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>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(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) {
|
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");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Void> logoutUser() {
|
public ResponseEntity<Void> logoutUser() {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
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 user) {
|
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 user) {
|
||||||
String accept = request.getHeader("Accept");
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user