From 108220a242c9e5351275b8dabc1b19dc184bd6ac Mon Sep 17 00:00:00 2001 From: Tanya Fesenko Date: Mon, 24 Sep 2018 21:38:24 -0400 Subject: [PATCH] Revert "Step 2: Generate Spring Boot code" --- .gitignore | 7 - ...pring (Boot + MVC + CloudFeign) Server.gen | 164 ------------- .../build.gradle | 33 --- .../pom.xml | 67 ----- .../.openapi-generator-ignore | 23 -- .../.openapi-generator/VERSION | 1 - .../springboot-petstore-demo/README.md | 18 -- .../springboot-petstore-demo/pom.xml | 62 ----- .../demo/springboot/OpenAPI2SpringBoot.java | 51 ---- .../demo/springboot/RFC3339DateFormat.java | 22 -- .../demo/springboot/api/ApiException.java | 10 - .../demo/springboot/api/ApiOriginFilter.java | 27 -- .../springboot/api/ApiResponseMessage.java | 69 ------ .../reprezen/demo/springboot/api/ApiUtil.java | 17 -- .../springboot/api/NotFoundException.java | 10 - .../reprezen/demo/springboot/api/PetsApi.java | 72 ------ .../springboot/api/PetsApiController.java | 50 ---- .../demo/springboot/api/PetsApiDelegate.java | 41 ---- .../reprezen/demo/springboot/model/Error.java | 105 -------- .../demo/springboot/model/NewPet.java | 104 -------- .../reprezen/demo/springboot/model/Pet.java | 81 ------ .../swaggerui/CustomInstantDeserializer.java | 232 ------------------ .../springboot/swaggerui/HomeController.java | 16 -- .../swaggerui/JacksonConfiguration.java | 23 -- .../swaggerui/OpenAPIDocumentationConfig.java | 69 ------ .../src/main/resources/application.properties | 4 - README.md | 26 +- 27 files changed, 3 insertions(+), 1401 deletions(-) delete mode 100644 Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/Java Spring (Boot + MVC + CloudFeign) Server.gen delete mode 100644 Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/build.gradle delete mode 100644 Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/pom.xml delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator-ignore delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator/VERSION delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/README.md delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/pom.xml delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/OpenAPI2SpringBoot.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/RFC3339DateFormat.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiException.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiOriginFilter.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiResponseMessage.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiUtil.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/NotFoundException.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApi.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiController.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiDelegate.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Error.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/NewPet.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Pet.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/CustomInstantDeserializer.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/HomeController.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/JacksonConfiguration.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/OpenAPIDocumentationConfig.java delete mode 100644 Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/resources/application.properties diff --git a/.gitignore b/.gitignore index d44e644..a1c2a23 100644 --- a/.gitignore +++ b/.gitignore @@ -21,10 +21,3 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* - -# Locally ignored (path-specific) files and directories. -*settings/ -*metadata/ - -# Generator trace file -*.trace.json diff --git a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/Java Spring (Boot + MVC + CloudFeign) Server.gen b/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/Java Spring (Boot + MVC + CloudFeign) Server.gen deleted file mode 100644 index 3699ded..0000000 --- a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/Java Spring (Boot + MVC + CloudFeign) Server.gen +++ /dev/null @@ -1,164 +0,0 @@ ---- -name: "Java Spring (Boot + MVC + CloudFeign) Server" -genTemplateId: "com.modelsolv.reprezen.gentemplates.openapi.generator.SpringCodegen" -relativeOutputDir: ../../../implementation/springboot-petstore-demo -prerequisites: null -primarySource: - path: "../../../models/petstore-expanded.yaml" -namedSources: null -# The parameters object contains variables that are processed directly by the GenTemplate. -parameters: - # Sort method arguments to place required parameters before optional parameters. - sortParamsByRequiredFlag: null - - # Whether to ensure parameter names are unique in an operation (rename parameters that are not). - ensureUniqueParams: null - - # boolean, toggles whether unicode identifiers are allowed in names or not, default is false - allowUnicodeIdentifiers: null - - # Add form or body parameters to the beginning of the parameter list. - prependFormOrBodyParameters: null - - # package for generated models - modelPackage: com.reprezen.demo.springboot.model - - # package for generated api classes - apiPackage: com.reprezen.demo.springboot.api - - # root package for generated code - invokerPackage: com.reprezen.demo.springboot - - # groupId in generated pom.xml - groupId: com.reprezen.demo - - # artifactId in generated pom.xml - artifactId: petstore-demo - - # artifact version in generated pom.xml - artifactVersion: null - - # artifact URL in generated pom.xml - artifactUrl: null - - # artifact description in generated pom.xml - artifactDescription: "Demontration of the Contract-as-Code approach with Spring Boot artifacts generated from an OpenAPI3 doc" - - # SCM connection in generated pom.xml - scmConnection: null - - # SCM developer connection in generated pom.xml - scmDeveloperConnection: null - - # SCM URL in generated pom.xml - scmUrl: null - - # developer name in generated pom.xml - developerName: null - - # developer email in generated pom.xml - developerEmail: null - - # developer organization in generated pom.xml - developerOrganization: null - - # developer organization URL in generated pom.xml - developerOrganizationUrl: null - - # The name of the license - licenseName: null - - # The URL of the license - licenseUrl: null - - # source folder for generated code - sourceFolder: null - - # prefix for generated code members and local variables - localVariablePrefix: null - - # boolean - toggle "implements Serializable" for generated models - serializableModel: null - - # Treat BigDecimal values as Strings to avoid precision loss. - bigDecimalAsString: null - - # whether to use fully qualified name for classes under java.util. This option only works for Java API client - fullJavaUtil: null - - # hides the timestamp when files were generated - hideGenerationTimestamp: true - - # whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML) - withXml: null - - # Option. Date library to use - dateLibrary: null - - # Option. Use Java8 classes instead of third party equivalents - java8: false - - # server title name or client service name - title: null - - # configuration package for generated code - configPackage: com.reprezen.demo.springboot.swaggerui - - # base package (invokerPackage) for generated code - basePackage: com.reprezen.demo.springboot - - # Whether to generate only API interface stubs without the server files. - interfaceOnly: false - - # Whether to generate the server files using the delegate pattern - delegatePattern: true - - # Whether to select only one produces/consumes content-type by operation. - singleContentTypes: null - - # use async Callable controllers - async: null - - # wrap responses in Mono/Flux Reactor types (spring-boot only) - reactive: null - - # wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type) - responseWrapper: null - - # use tags for creating interface and controller classnames - useTags: null - - # Use BeanValidation API annotations - useBeanValidation: null - - # Use of @ApiImplicitParams for headers. - implicitHeaders: null - - # Generate Spring OpenAPI Docket configuration class. - swaggerDocketConfig: null - - # Use Optional container for optional parameters - useOptional: null - - # library template (sub-template) to use - library: null - - # Contents of OpenAPI Generator configuration file. - # This is the file that would be passed with --config option on OpenAPI Generator commandline. - # The JSON contents of that file should be the value of this parameter. - # This parameter need not be used. If it is absent, all string-valued parameters are collected into - # a map that is then passed to the OpenAPI Generator module. If a map is provided here, then string-valued - # parameters are still copied in, overriding like-named values appearing in the map. - openApiCodegenConfig: - hideGenerationTimestamp: true - delegatePattern: true - # the java8 option generates default methods in interfaces which. Because of it, unimplemented methods in interface implementations will NOT be detected by the compiler. - java8: false - - # System properties to set, as in the -D option of OpenAPI Generatorcommand line. - # Each property should be a json object with a name/value pair for each property. - # Example: for '-Dmodels -Dapis=User,Pets' use the following: - # value: - # models: '' - # apis: Users,Pets - openApiCodegenSystemProperties: null diff --git a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/build.gradle b/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/build.gradle deleted file mode 100644 index 42e28d7..0000000 --- a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -apply plugin: 'java' - - repositories { - maven { - url "http://maven.reprezen.com/repository/releases" - } - maven { - url "http://maven.reprezen.com/repository/eclipse/" - } - mavenCentral() - } - - dependencies { - compile ('com.modelsolv.reprezen:com.modelsolv.reprezen.generators.api:1.6.11.9445') - compile ('com.modelsolv.reprezen:com.modelsolv.reprezen.generators.xtend:1.6.11.9445') { - exclude module: 'org.eclipse.equinox.bidi' - exclude module: 'org.eclipse.emf.common.ui' - exclude module: 'org.eclipse.e4.ui.workbench3' - exclude module: 'org.apache.batik.css' - exclude module: 'org.eclipse.e4.ui.css.swt' - } - compile ('com.modelsolv.reprezen:com.modelsolv.reprezen.generators.standard:1.6.11.9445') - compile fileTree(dir: '/Users/tanya/RepreZen/workspace/shared/GenTemplates', include: ['*.jar']) - compile fileTree(dir: '/Users/tanya/Documents/workspace/Contract-as-Code-Demo-OpenAPI3---Spring-Boot/Expanded Pet Store (v3)/lib', include: ['*.jar']) - } - - task(execGenTarget, dependsOn: 'classes', type: JavaExec) { - main = 'com.modelsolv.reprezen.generators.api.util.GeneratorLauncher' - classpath = sourceSets.main.runtimeClasspath - args '/Users/tanya/Documents/workspace/Contract-as-Code-Demo-OpenAPI3---Spring-Boot/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/Java Spring (Boot + MVC + CloudFeign) Server.gen' - } - - defaultTasks 'execGenTarget' diff --git a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/pom.xml b/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/pom.xml deleted file mode 100644 index aa31b3e..0000000 --- a/Expanded Pet Store (v3)/gentargets/petstore-expanded/Java Spring (Boot + MVC + CloudFeign) Server/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - - com.modelsolv.reprezen.generators - pet-store-expanded - 1.0-SNAPSHOT - ../../../pom.xml - - java-spring--boot---mvc---cloudfeign--server-gen - GenTarget Launcher For Java Spring (Boot + MVC + CloudFeign) Server.gen - pom - - /Users/tanya/Documents/workspace/Contract-as-Code-Demo-OpenAPI3---Spring-Boot/Expanded Pet Store (v3)/lib - /Users/tanya/RepreZen/workspace/shared/GenTemplates - - - clean generate-sources - - - com.googlecode.addjars-maven-plugin - addjars-maven-plugin - 1.0.5 - - - generate-sources - - add-jars - - - - - ${shared.gentemplates.dir} - - - ${project.lib.dir} - - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.4.0 - - - generate-sources - - java - - - - - true - com.modelsolv.reprezen.generators.api.util.GeneratorLauncher - compile - false - - Java Spring (Boot + MVC + CloudFeign) Server.gen - - - - - - \ No newline at end of file diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator-ignore b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator-ignore deleted file mode 100644 index 7484ee5..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator/VERSION b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator/VERSION deleted file mode 100644 index 06eda28..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.2.3 \ No newline at end of file diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/README.md b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/README.md deleted file mode 100644 index 764a5cc..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# OpenAPI generated server - -Spring Boot Server - - -## Overview -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 SpringBoot framework. - -The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) - -Start your server as a simple java application - -You can view the api documentation in swagger-ui by pointing to -http://localhost:8080/ - -Change default port value in application.properties \ No newline at end of file diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/pom.xml b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/pom.xml deleted file mode 100644 index 10cac49..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - 4.0.0 - com.reprezen.demo - petstore-demo - jar - petstore-demo - 1.0.0 - - 1.7 - ${java.version} - ${java.version} - 2.8.0 - - - org.springframework.boot - spring-boot-starter-parent - 1.5.12.RELEASE - - - src/main/java - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - - com.github.joschi.jackson - jackson-datatype-threetenbp - 2.8.4 - - - - javax.validation - validation-api - - - diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/OpenAPI2SpringBoot.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/OpenAPI2SpringBoot.java deleted file mode 100644 index 2e07e4f..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.reprezen.demo.springboot; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.ExitCodeGenerator; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@SpringBootApplication -@ComponentScan(basePackages = {"com.reprezen.demo.springboot", "com.reprezen.demo.springboot.api" , "com.reprezen.demo.springboot.swaggerui"}) -public class OpenAPI2SpringBoot implements CommandLineRunner { - - @Override - public void run(String... arg0) throws Exception { - if (arg0.length > 0 && arg0[0].equals("exitcode")) { - throw new ExitException(); - } - } - - public static void main(String[] args) throws Exception { - new SpringApplication(OpenAPI2SpringBoot.class).run(args); - } - - class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } - - @Bean - public WebMvcConfigurer webConfigurer() { - return new WebMvcConfigurerAdapter() { - /*@Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("*") - .allowedHeaders("Content-Type"); - }*/ - }; - } - -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/RFC3339DateFormat.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/RFC3339DateFormat.java deleted file mode 100644 index 9dfbe42..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/RFC3339DateFormat.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.reprezen.demo.springboot; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiException.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiException.java deleted file mode 100644 index aece227..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.reprezen.demo.springboot.api; - - -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiOriginFilter.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiOriginFilter.java deleted file mode 100644 index 073dca5..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiOriginFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.reprezen.demo.springboot.api; - -import java.io.IOException; - -import javax.servlet.*; -import javax.servlet.http.HttpServletResponse; - - -public class ApiOriginFilter implements javax.servlet.Filter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - @Override - public void destroy() { - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiResponseMessage.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiResponseMessage.java deleted file mode 100644 index 42c5d11..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiResponseMessage.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.reprezen.demo.springboot.api; - -import javax.xml.bind.annotation.XmlTransient; - - -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; - - int code; - String type; - String message; - - public ApiResponseMessage(){} - - public ApiResponseMessage(int code, String message){ - this.code = code; - switch(code){ - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiUtil.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiUtil.java deleted file mode 100644 index f6014ce..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/ApiUtil.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.reprezen.demo.springboot.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); - } - } -} \ No newline at end of file diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/NotFoundException.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/NotFoundException.java deleted file mode 100644 index a7f3323..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/NotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.reprezen.demo.springboot.api; - - -public class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApi.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApi.java deleted file mode 100644 index 468b2fe..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApi.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.2.3). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package com.reprezen.demo.springboot.api; - -import com.reprezen.demo.springboot.model.Error; -import com.reprezen.demo.springboot.model.NewPet; -import com.reprezen.demo.springboot.model.Pet; -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.Valid; -import javax.validation.constraints.*; -import java.util.List; -import java.util.Map; - -@Validated -@Api(value = "pets", description = "the pets API") -public interface PetsApi { - - @ApiOperation(value = "", nickname = "addPet", notes = "Creates a new pet in the store. Duplicates are allowed", response = Pet.class, tags={ }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "pet response", response = Pet.class), - @ApiResponse(code = 200, message = "unexpected error", response = Error.class) }) - @RequestMapping(value = "/pets", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet to add to the store" ,required=true ) @Valid @RequestBody NewPet newPet); - - - @ApiOperation(value = "", nickname = "deletePet", notes = "deletes a single pet based on the ID supplied", tags={ }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "pet deleted"), - @ApiResponse(code = 200, message = "unexpected error", response = Error.class) }) - @RequestMapping(value = "/pets/{id}", - produces = { "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "ID of pet to delete",required=true) @PathVariable("id") Long id); - - - @ApiOperation(value = "", nickname = "findPetById", notes = "Returns a user based on a single ID, if the user does not have access to the pet", response = Pet.class, tags={ }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "pet response", response = Pet.class), - @ApiResponse(code = 200, message = "unexpected error", response = Error.class) }) - @RequestMapping(value = "/pets/{id}", - produces = { "application/json" }, - method = RequestMethod.GET) - ResponseEntity findPetById(@ApiParam(value = "ID of pet to fetch",required=true) @PathVariable("id") Long id); - - - @ApiOperation(value = "", nickname = "findPets", notes = "Returns all pets from the system that the user has access to Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. ", response = Pet.class, responseContainer = "List", tags={ }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "pet response", response = Pet.class, responseContainer = "List"), - @ApiResponse(code = 200, message = "unexpected error", response = Error.class) }) - @RequestMapping(value = "/pets", - produces = { "application/json" }, - method = RequestMethod.GET) - ResponseEntity> findPets(@ApiParam(value = "tags to filter by") @Valid @RequestParam(value = "tags", required = false) List tags,@ApiParam(value = "maximum number of results to return") @Valid @RequestParam(value = "limit", required = false) Integer limit); - -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiController.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiController.java deleted file mode 100644 index 7758ad6..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiController.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.reprezen.demo.springboot.api; - -import com.reprezen.demo.springboot.model.Error; -import com.reprezen.demo.springboot.model.NewPet; -import com.reprezen.demo.springboot.model.Pet; -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -@Controller -@RequestMapping("${openapi.swaggerPetstore.base-path:/api}") -public class PetsApiController implements PetsApi { - - private final PetsApiDelegate delegate; - - public PetsApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetsApiDelegate delegate) { - this.delegate = delegate; - } - - public ResponseEntity addPet(@ApiParam(value = "Pet to add to the store" ,required=true ) @Valid @RequestBody NewPet newPet) { - return delegate.addPet(newPet); - } - - public ResponseEntity deletePet(@ApiParam(value = "ID of pet to delete",required=true) @PathVariable("id") Long id) { - return delegate.deletePet(id); - } - - public ResponseEntity findPetById(@ApiParam(value = "ID of pet to fetch",required=true) @PathVariable("id") Long id) { - return delegate.findPetById(id); - } - - public ResponseEntity> findPets(@ApiParam(value = "tags to filter by") @Valid @RequestParam(value = "tags", required = false) List tags,@ApiParam(value = "maximum number of results to return") @Valid @RequestParam(value = "limit", required = false) Integer limit) { - return delegate.findPets(tags, limit); - } - -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiDelegate.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiDelegate.java deleted file mode 100644 index aea71c8..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/api/PetsApiDelegate.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.reprezen.demo.springboot.api; - -import com.reprezen.demo.springboot.model.Error; -import com.reprezen.demo.springboot.model.NewPet; -import com.reprezen.demo.springboot.model.Pet; -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import java.util.Map; - -/** - * A delegate to be called by the {@link PetsApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ - -public interface PetsApiDelegate { - - /** - * @see PetsApi#addPet - */ - ResponseEntity addPet( NewPet newPet); - - /** - * @see PetsApi#deletePet - */ - ResponseEntity deletePet( Long id); - - /** - * @see PetsApi#findPetById - */ - ResponseEntity findPetById( Long id); - - /** - * @see PetsApi#findPets - */ - ResponseEntity> findPets( List tags, - Integer limit); - -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Error.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Error.java deleted file mode 100644 index dcd272f..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Error.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.reprezen.demo.springboot.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.Valid; -import javax.validation.constraints.*; - -/** - * Error - */ - -public class Error { - @JsonProperty("code") - private Integer code = null; - - @JsonProperty("message") - private String message = null; - - public Error code(Integer code) { - this.code = code; - return this; - } - - /** - * Get code - * @return code - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public Error message(String message) { - this.message = message; - return this; - } - - /** - * Get message - * @return message - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Error error = (Error) o; - return Objects.equals(this.code, error.code) && - Objects.equals(this.message, error.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Error {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).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 "); - } -} - diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/NewPet.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/NewPet.java deleted file mode 100644 index 8320dd9..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/NewPet.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.reprezen.demo.springboot.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.Valid; -import javax.validation.constraints.*; - -/** - * NewPet - */ - -public class NewPet { - @JsonProperty("name") - private String name = null; - - @JsonProperty("tag") - private String tag = null; - - public NewPet name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public NewPet tag(String tag) { - this.tag = tag; - return this; - } - - /** - * Get tag - * @return tag - **/ - @ApiModelProperty(value = "") - - - public String getTag() { - return tag; - } - - public void setTag(String tag) { - this.tag = tag; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NewPet newPet = (NewPet) o; - return Objects.equals(this.name, newPet.name) && - Objects.equals(this.tag, newPet.tag); - } - - @Override - public int hashCode() { - return Objects.hash(name, tag); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NewPet {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" tag: ").append(toIndentedString(tag)).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 "); - } -} - diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Pet.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Pet.java deleted file mode 100644 index 4c488dc..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/model/Pet.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.reprezen.demo.springboot.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.reprezen.demo.springboot.model.NewPet; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.Valid; -import javax.validation.constraints.*; - -/** - * Pet - */ - -public class Pet extends NewPet { - @JsonProperty("id") - private Long id = null; - - public Pet id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Pet pet = (Pet) o; - return Objects.equals(this.id, pet.id) && - super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(id, super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).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 "); - } -} - diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/CustomInstantDeserializer.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/CustomInstantDeserializer.java deleted file mode 100644 index 65eaff2..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.reprezen.demo.springboot.swaggerui; - -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.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.DateTimeUtils; -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 - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(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.toZoneId(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; - } - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/HomeController.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/HomeController.java deleted file mode 100644 index a28370b..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/HomeController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.reprezen.demo.springboot.swaggerui; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - @RequestMapping(value = "/") - public String index() { - System.out.println("swagger-ui.html"); - return "redirect:swagger-ui.html"; - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/JacksonConfiguration.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/JacksonConfiguration.java deleted file mode 100644 index dabf783..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.reprezen.demo.springboot.swaggerui; - -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; - } -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/OpenAPIDocumentationConfig.java b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/OpenAPIDocumentationConfig.java deleted file mode 100644 index 092d10f..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/java/com/reprezen/demo/springboot/swaggerui/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.reprezen.demo.springboot.swaggerui; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -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.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.servlet.ServletContext; - - -@Configuration -@EnableSwagger2 -public class OpenAPIDocumentationConfig { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("Swagger Petstore") - .description("A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification") - .license("MIT") - .licenseUrl("http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT") - .termsOfServiceUrl("http://madskristensen.net") - .version("1.0.0") - .contact(new Contact("","", "foo@example.com")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.swaggerPetstore.base-path:/api}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("com.reprezen.demo.springboot.api")) - .build() - .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/resources/application.properties b/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/resources/application.properties deleted file mode 100644 index a3d004b..0000000 --- a/Expanded Pet Store (v3)/implementation/springboot-petstore-demo/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.port=8080 -spring.jackson.date-format=com.reprezen.demo.springboot.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false \ No newline at end of file diff --git a/README.md b/README.md index 4c82ac8..53db148 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,13 @@ -# API CodeFlow Spring Boot -Creating a Spring Boot app from an OpenAPI3 document with [SpringCodegen](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java) +# Contract-as-Code-Demo-OpenAPI3---Spring-Boot +Demo for OpenAPI3 to Spring Boot generator +## Work in Progress -To run the code locally -1. `git checkout final` -2. Navigate to the Spring Boot directory: `cd 'Expanded Pet Store (v3)/implementation/springboot-petstore-demo/'` -3. `mvn spring-boot:run` -4. Access API at this URI: http://localhost:8080/api/pets/ - -To learn more about the Contract-as-Code approach, watch our presentation: [API Contract-As-Code: Rapid Development with OpenAPI](https://www.slideshare.net/TedEpstein/api-contractascode-rapid-development-with-openapi) - - -# Work in Progress -## Step 1: Design -Describe your RESTful API * step_1a Create "Expanded Pet Store" Project * step_1b Add GenTarget for "Java Spring (Boot + MVC + CloudFeign) Server" * step_1c Modify output folder and packages in the *.gen file - -## Step 2: Generate and Implement -Generate code and add customizations * step_2a Generate code * step_2b Add implementation to the code - -Now you can run the API locally as described above. - -## Step 3: Iterate * step_3a Add a new method to the OAS document * step_3b Re-generate code * step_3c Add missing implementation - - * ...