From 04cc4bedfada054b97cb60a14691565a9fc6c6dd Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 22 Aug 2020 11:17:42 -0400 Subject: [PATCH 1/4] FILES is now path relative with no prefixes some Java implementations don't honor .relativize documentation fully. When outDir is /a/b and the input is /a/b/c/d, the result should be c/d. Some implementations make the output ./c/d which seems to mix the logic as documented for symlinks. So we need to trim any / or ./ from the start, as nobody should be generating into system root and our expectation is no ./ This resolves regeneration issues for those on such Java implementations, although we've not been able to track down the exact vendor or configurations which might lead to these differences. --- .../codegen/DefaultGenerator.java | 12 ++++- .../.openapi-generator/FILES | 46 +++++++++---------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index c73e1f5fb131..28db5d9298a9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -60,6 +60,7 @@ import java.util.*; import java.util.stream.Collectors; +import static org.apache.commons.lang3.StringUtils.removeStart; import static org.openapitools.codegen.utils.OnceLogger.once; @SuppressWarnings("rawtypes") @@ -1351,10 +1352,17 @@ private void generateFilesMetadata(List files) { } }); + String relativeMeta = METADATA_DIR + File.separator + "VERSION"; filesToSort.sort(PathFileComparator.PATH_COMPARATOR); filesToSort.forEach(f -> { - String relativePath = outDir.toPath().relativize(f.toPath()).toString(); - if (!relativePath.equals(METADATA_DIR + File.separator + "VERSION")) { + String tmp = outDir.toPath().relativize(f.toPath()).toString(); + // some Java implementations don't honor .relativize documentation fully. + // When outDir is /a/b and the input is /a/b/c/d, the result should be c/d. + // Some implementations make the output ./c/d which seems to mix the logic + // as documented for symlinks. So we need to trim any / or ./ from the start, + // as nobody should be generating into system root and our expectation is no ./ + String relativePath = removeStart(removeStart(tmp, "./"), "/"); + if (!relativePath.equals(relativeMeta)) { sb.append(relativePath).append(System.lineSeparator()); } }); diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES index b00a0510b77f..8c41d6e8cf56 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES @@ -1,26 +1,26 @@ -./Api/ApiServer.php -./Api/PetApiInterface.php -./Api/StoreApiInterface.php -./Api/UserApiInterface.php -./Controller/Controller.php -./Controller/PetController.php -./Controller/StoreController.php -./Controller/UserController.php -./Model/ApiResponse.php -./Model/Category.php -./Model/Order.php -./Model/Pet.php -./Model/Tag.php -./Model/User.php -./Service/JmsSerializer.php -./Service/SerializerInterface.php -./Service/StrictJsonDeserializationVisitor.php -./Service/SymfonyValidator.php -./Service/TypeMismatchException.php -./Service/ValidatorInterface.php -./Tests/AppKernel.php -./Tests/Controller/ControllerTest.php -./Tests/test_config.yml +Api/ApiServer.php +Api/PetApiInterface.php +Api/StoreApiInterface.php +Api/UserApiInterface.php +Controller/Controller.php +Controller/PetController.php +Controller/StoreController.php +Controller/UserController.php +Model/ApiResponse.php +Model/Category.php +Model/Order.php +Model/Pet.php +Model/Tag.php +Model/User.php +Service/JmsSerializer.php +Service/SerializerInterface.php +Service/StrictJsonDeserializationVisitor.php +Service/SymfonyValidator.php +Service/TypeMismatchException.php +Service/ValidatorInterface.php +Tests/AppKernel.php +Tests/Controller/ControllerTest.php +Tests/test_config.yml .coveralls.yml .gitignore .php_cs.dist From 26bd49f2470cf8e460f3bec5e0f8cbc960f7e21a Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 22 Aug 2020 11:30:47 -0400 Subject: [PATCH 2/4] Ensure windows outputs FILES paths in same format --- .../java/org/openapitools/codegen/DefaultGenerator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 28db5d9298a9..a35ae75ab599 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1361,7 +1361,11 @@ private void generateFilesMetadata(List files) { // Some implementations make the output ./c/d which seems to mix the logic // as documented for symlinks. So we need to trim any / or ./ from the start, // as nobody should be generating into system root and our expectation is no ./ - String relativePath = removeStart(removeStart(tmp, "./"), "/"); + String relativePath = removeStart(removeStart(tmp, "." + File.separator), File.separator); + if (File.separator.equals("\\")) { + // ensure that windows outputs same FILES format + relativePath = relativePath.replace(File.separator, "/"); + } if (!relativePath.equals(relativeMeta)) { sb.append(relativePath).append(System.lineSeparator()); } From 991f511aee0eeb5acab0ea39a52803296971cad5 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 22 Aug 2020 14:14:45 -0400 Subject: [PATCH 3/4] Normalize FILES paths to remove relativization mid-path --- .../main/java/org/openapitools/codegen/DefaultGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index a35ae75ab599..7e7bf97f64fe 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1355,7 +1355,7 @@ private void generateFilesMetadata(List files) { String relativeMeta = METADATA_DIR + File.separator + "VERSION"; filesToSort.sort(PathFileComparator.PATH_COMPARATOR); filesToSort.forEach(f -> { - String tmp = outDir.toPath().relativize(f.toPath()).toString(); + String tmp = outDir.toPath().relativize(f.toPath()).normalize().toString(); // some Java implementations don't honor .relativize documentation fully. // When outDir is /a/b and the input is /a/b/c/d, the result should be c/d. // Some implementations make the output ./c/d which seems to mix the logic From af8f0e684c71794664cd53121bc285b04a15e5e9 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 22 Aug 2020 14:14:59 -0400 Subject: [PATCH 4/4] [samples] Regenerate --- .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../typescript-node/default/.openapi-generator/FILES | 12 ++++++------ .../typescript-node/npm/.openapi-generator/FILES | 12 ++++++------ 17 files changed, 102 insertions(+), 102 deletions(-) diff --git a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES index c4f1df469e4b..ff52c7c5b2b8 100644 --- a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES @@ -5,10 +5,10 @@ api/petApi.ts api/storeApi.ts api/userApi.ts git_push.sh -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts diff --git a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES index 914f5ced854a..d24a1934784b 100644 --- a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES @@ -5,12 +5,12 @@ api/petApi.ts api/storeApi.ts api/userApi.ts git_push.sh -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts package.json tsconfig.json