From 5a3d77247f7741b799240c61cc7a9b0cece3c0c6 Mon Sep 17 00:00:00 2001 From: bnasslahsen Date: Sun, 5 Apr 2020 16:49:50 +0200 Subject: [PATCH] review cache configuration --- .../api/AbstractOpenApiResource.java | 7 +- .../org/springdoc/core/OpenAPIBuilder.java | 4 + springdoc-openapi-groovy/.gitignore | 144 ++++++++++++++++++ .../test/test/org/springdoc/api/app1/Car.java | 23 --- .../org/springdoc/api/app1/CarController.java | 25 --- .../org/springdoc/api/app1/CarService.java | 21 --- .../api/app1/OpenApiConfiguration.java | 20 --- .../compile/default-compile/createdFiles.lst | 1 - .../compile/default-compile/inputFiles.lst | 1 - .../default-testCompile/createdFiles.lst | 7 - .../default-testCompile/inputFiles.lst | 6 - ...g.springdoc.api.app1.SpringDocApp1Test.xml | 64 -------- ...g.springdoc.api.app1.SpringDocApp1Test.txt | 4 - .../test-classes/application-test.properties | 19 --- .../target/test-classes/logback-test.xml | 4 - .../target/test-classes/results/app1.json | 85 ----------- .../core/SpringDocWebMvcConfiguration.java | 2 +- 17 files changed, 151 insertions(+), 286 deletions(-) create mode 100644 springdoc-openapi-groovy/.gitignore delete mode 100644 springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/Car.java delete mode 100644 springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarController.java delete mode 100644 springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarService.java delete mode 100644 springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/OpenApiConfiguration.java delete mode 100644 springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 springdoc-openapi-groovy/target/surefire-reports/TEST-test.org.springdoc.api.app1.SpringDocApp1Test.xml delete mode 100644 springdoc-openapi-groovy/target/surefire-reports/test.org.springdoc.api.app1.SpringDocApp1Test.txt delete mode 100644 springdoc-openapi-groovy/target/test-classes/application-test.properties delete mode 100644 springdoc-openapi-groovy/target/test-classes/logback-test.xml delete mode 100644 springdoc-openapi-groovy/target/test-classes/results/app1.json diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java index 4a4d80187..658c969d9 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java @@ -95,8 +95,6 @@ public abstract class AbstractOpenApiResource extends SpecFilter { private final String groupName; - private boolean computeDone; - protected AbstractOpenApiResource(String groupName, OpenAPIBuilder openAPIBuilder, AbstractRequestBuilder requestBuilder, GenericResponseBuilder responseBuilder, OperationBuilder operationParser, @@ -124,9 +122,9 @@ public static void addDeprecatedType(Class cls) { DEPRECATED_TYPES.add(cls); } - protected synchronized OpenAPI getOpenApi() { + protected OpenAPI getOpenApi() { OpenAPI openApi; - if (!computeDone || springDocConfigProperties.isCacheDisabled()) { + if (openAPIBuilder.getCachedOpenAPI() == null || springDocConfigProperties.isCacheDisabled()) { Instant start = Instant.now(); openAPIBuilder.build(); Map mappingsMap = openAPIBuilder.getMappingsMap().entrySet().stream() @@ -142,7 +140,6 @@ protected synchronized OpenAPI getOpenApi() { getPaths(mappingsMap); // run the optional customisers openApiCustomisers.ifPresent(apiCustomisers -> apiCustomisers.forEach(openApiCustomiser -> openApiCustomiser.customise(openApi))); - computeDone = true; if (springDocConfigProperties.isRemoveBrokenReferenceDefinitions()) this.removeBrokenReferenceDefinitions(openApi); openAPIBuilder.setCachedOpenAPI(openApi); diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIBuilder.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIBuilder.java index 68033387b..d7aef908f 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIBuilder.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIBuilder.java @@ -451,6 +451,10 @@ public void setCachedOpenAPI(OpenAPI cachedOpenAPI) { this.cachedOpenAPI = cachedOpenAPI; } + public OpenAPI getCachedOpenAPI() { + return cachedOpenAPI; + } + public OpenAPI getCalculatedOpenAPI() { return calculatedOpenAPI; } diff --git a/springdoc-openapi-groovy/.gitignore b/springdoc-openapi-groovy/.gitignore new file mode 100644 index 000000000..ab21548c1 --- /dev/null +++ b/springdoc-openapi-groovy/.gitignore @@ -0,0 +1,144 @@ +###################### +# Project Specific +###################### +/target/www/** +/src/test/javascript/coverage/ + +###################### +# Node +###################### +/node/ +node_tmp/ +node_modules/ +npm-debug.log.* +/.awcache/* +/.cache-loader/* + +###################### +# SASS +###################### +.sass-cache/ + +###################### +# Eclipse +###################### +*.pydevproject +.project +.metadata +tmp/ +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +.factorypath +/src/main/resources/rebel.xml + +# External tool builders +.externalToolBuilders/** + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +###################### +# Intellij +###################### +.idea/ +*.iml +*.iws +*.ipr +*.ids +*.orig +classes/ +out/ + +###################### +# Visual Studio Code +###################### +.vscode/ + +###################### +# Maven +###################### +/log/ +/target/ + +###################### +# Gradle +###################### +.gradle/ +/build/ + +###################### +# Package Files +###################### +*.jar +*.war +*.ear +*.db + +###################### +# Windows +###################### +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# Mac OSX +###################### +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +###################### +# Directories +###################### +/bin/ +/deploy/ + +###################### +# Logs +###################### +*.log* + +###################### +# Others +###################### +*.class +*.*~ +*~ +.merge_file* + +###################### +# Gradle Wrapper +###################### +!gradle/wrapper/gradle-wrapper.jar + +###################### +# Maven Wrapper +###################### +!.mvn/wrapper/maven-wrapper.jar + +###################### +# ESLint +###################### +.eslintcache \ No newline at end of file diff --git a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/Car.java b/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/Car.java deleted file mode 100644 index 8f6e1aa28..000000000 --- a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/Car.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app1; - -import java.lang.*; -import java.io.*; -import java.net.*; -import java.util.*; -import groovy.lang.*; -import groovy.util.*; - -public class Car - extends java.lang.Object implements - groovy.lang.GroovyObject { -; -@groovy.transform.Generated() @groovy.transform.Internal() public groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setMetaClass(groovy.lang.MetaClass mc) { } -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object getProperty(java.lang.String property) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setProperty(java.lang.String property, java.lang.Object value) { } -public java.lang.Long getId() { return (java.lang.Long)null;} -public void setId(java.lang.Long value) { } -public java.lang.String getName() { return (java.lang.String)null;} -public void setName(java.lang.String value) { } -} diff --git a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarController.java b/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarController.java deleted file mode 100644 index 8e7982dd9..000000000 --- a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarController.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app1; - -import java.lang.*; -import java.io.*; -import java.net.*; -import java.util.*; -import groovy.lang.*; -import groovy.util.*; - -@org.springframework.web.bind.annotation.RestController() public class CarController - extends java.lang.Object implements - groovy.lang.GroovyObject { -; -public CarController -(test.org.springdoc.api.app1.CarService carService) {} -@groovy.transform.Generated() @groovy.transform.Internal() public groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setMetaClass(groovy.lang.MetaClass mc) { } -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object getProperty(java.lang.String property) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setProperty(java.lang.String property, java.lang.Object value) { } -public test.org.springdoc.api.app1.CarService getCarService() { return (test.org.springdoc.api.app1.CarService)null;} -public void setCarService(test.org.springdoc.api.app1.CarService value) { } -@org.springframework.web.bind.annotation.GetMapping(path="/cars") public java.util.List getCars() { return (java.util.List)null;} -@org.springframework.web.bind.annotation.GetMapping(path="cars/{carId}") public test.org.springdoc.api.app1.Car getCar(@org.springframework.web.bind.annotation.PathVariable(value="carId") java.lang.Long carId) { return (test.org.springdoc.api.app1.Car)null;} -} diff --git a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarService.java b/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarService.java deleted file mode 100644 index f9c445f49..000000000 --- a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/CarService.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app1; - -import java.lang.*; -import java.io.*; -import java.net.*; -import java.util.*; -import groovy.lang.*; -import groovy.util.*; - -@org.springframework.stereotype.Service() public class CarService - extends java.lang.Object implements - groovy.lang.GroovyObject { -; -@groovy.transform.Generated() @groovy.transform.Internal() public groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setMetaClass(groovy.lang.MetaClass mc) { } -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object getProperty(java.lang.String property) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setProperty(java.lang.String property, java.lang.Object value) { } -public java.util.List getCars() { return (java.util.List)null;} -public test.org.springdoc.api.app1.Car getCar(java.lang.Long carId) { return (test.org.springdoc.api.app1.Car)null;} -} diff --git a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/OpenApiConfiguration.java b/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/OpenApiConfiguration.java deleted file mode 100644 index cb645a2b8..000000000 --- a/springdoc-openapi-groovy/target/generated-sources/groovy-stubs/test/test/org/springdoc/api/app1/OpenApiConfiguration.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app1; - -import java.lang.*; -import java.io.*; -import java.net.*; -import java.util.*; -import groovy.lang.*; -import groovy.util.*; - -@io.swagger.v3.oas.annotations.OpenAPIDefinition() @org.springframework.context.annotation.Configuration() public class OpenApiConfiguration - extends java.lang.Object implements - groovy.lang.GroovyObject { -; -@groovy.transform.Generated() @groovy.transform.Internal() public groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setMetaClass(groovy.lang.MetaClass mc) { } -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public java.lang.Object getProperty(java.lang.String property) { return null;} -@groovy.transform.Generated() @groovy.transform.Internal() public void setProperty(java.lang.String property, java.lang.Object value) { } -@org.springframework.context.annotation.Bean() public io.swagger.v3.oas.models.OpenAPI customOpenAPI() { return (io.swagger.v3.oas.models.OpenAPI)null;} -} diff --git a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index 7c5ba318f..000000000 --- a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1 +0,0 @@ -org\springdoc\groovy\SpringDocGroovyConfiguration.class diff --git a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 2ef8d0fc8..000000000 --- a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\src\main\java\org\springdoc\groovy\SpringDocGroovyConfiguration.java diff --git a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst deleted file mode 100644 index 050f258e8..000000000 --- a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +++ /dev/null @@ -1,7 +0,0 @@ -test\org\springdoc\api\app1\SpringDocApp1Test$SpringDocTestApp.class -test\org\springdoc\api\AbstractSpringDocTest.class -test\org\springdoc\api\app1\SpringDocApp1Test.class -test\org\springdoc\api\app1\CarService.class -test\org\springdoc\api\app1\OpenApiConfiguration.class -test\org\springdoc\api\app1\Car.class -test\org\springdoc\api\app1\CarController.class diff --git a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index ee7d705e2..000000000 --- a/springdoc-openapi-groovy/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ /dev/null @@ -1,6 +0,0 @@ -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\src\test\groovy\test\org\springdoc\api\AbstractSpringDocTest.java -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\src\test\groovy\test\org\springdoc\api\app1\SpringDocApp1Test.java -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\target\generated-sources\groovy-stubs\test\test\org\springdoc\api\app1\OpenApiConfiguration.java -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\target\generated-sources\groovy-stubs\test\test\org\springdoc\api\app1\CarController.java -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\target\generated-sources\groovy-stubs\test\test\org\springdoc\api\app1\CarService.java -C:\partage\workspaces\workspace-ddd\spring-doc-review\springdoc-openapi\springdoc-openapi-groovy\target\generated-sources\groovy-stubs\test\test\org\springdoc\api\app1\Car.java diff --git a/springdoc-openapi-groovy/target/surefire-reports/TEST-test.org.springdoc.api.app1.SpringDocApp1Test.xml b/springdoc-openapi-groovy/target/surefire-reports/TEST-test.org.springdoc.api.app1.SpringDocApp1Test.xml deleted file mode 100644 index e399820ca..000000000 --- a/springdoc-openapi-groovy/target/surefire-reports/TEST-test.org.springdoc.api.app1.SpringDocApp1Test.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/springdoc-openapi-groovy/target/surefire-reports/test.org.springdoc.api.app1.SpringDocApp1Test.txt b/springdoc-openapi-groovy/target/surefire-reports/test.org.springdoc.api.app1.SpringDocApp1Test.txt deleted file mode 100644 index a92314201..000000000 --- a/springdoc-openapi-groovy/target/surefire-reports/test.org.springdoc.api.app1.SpringDocApp1Test.txt +++ /dev/null @@ -1,4 +0,0 @@ -------------------------------------------------------------------------------- -Test set: test.org.springdoc.api.app1.SpringDocApp1Test -------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.257 s - in test.org.springdoc.api.app1.SpringDocApp1Test diff --git a/springdoc-openapi-groovy/target/test-classes/application-test.properties b/springdoc-openapi-groovy/target/test-classes/application-test.properties deleted file mode 100644 index 7bb0eb9e2..000000000 --- a/springdoc-openapi-groovy/target/test-classes/application-test.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# /* -# * Copyright 2019-2020 the original author or authors. -# * -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * https://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# */ -# -spring.main.banner-mode:"off" -logging.level.root=OFF \ No newline at end of file diff --git a/springdoc-openapi-groovy/target/test-classes/logback-test.xml b/springdoc-openapi-groovy/target/test-classes/logback-test.xml deleted file mode 100644 index 608cb302d..000000000 --- a/springdoc-openapi-groovy/target/test-classes/logback-test.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/springdoc-openapi-groovy/target/test-classes/results/app1.json b/springdoc-openapi-groovy/target/test-classes/results/app1.json deleted file mode 100644 index 95e01799b..000000000 --- a/springdoc-openapi-groovy/target/test-classes/results/app1.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Issue OpenAPI with Groovy", - "description": "Special Groovy Metaclass Test Issue" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/cars": { - "get": { - "tags": [ - "car-controller" - ], - "operationId": "getCars", - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Car" - } - } - } - } - } - } - } - }, - "/cars/{carId}": { - "get": { - "tags": [ - "car-controller" - ], - "operationId": "getCar", - "parameters": [ - { - "name": "carId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/Car" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Car": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - } - } - } -} diff --git a/springdoc-openapi-webmvc-core/src/main/java/org/springdoc/webmvc/core/SpringDocWebMvcConfiguration.java b/springdoc-openapi-webmvc-core/src/main/java/org/springdoc/webmvc/core/SpringDocWebMvcConfiguration.java index 636dc794c..218c0b8a4 100644 --- a/springdoc-openapi-webmvc-core/src/main/java/org/springdoc/webmvc/core/SpringDocWebMvcConfiguration.java +++ b/springdoc-openapi-webmvc-core/src/main/java/org/springdoc/webmvc/core/SpringDocWebMvcConfiguration.java @@ -89,7 +89,7 @@ GenericResponseBuilder responseBuilder(OperationBuilder operationBuilder, List