From b7a24384532e766d48ea6a84054bf76c8704cf1b Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 15 Oct 2020 22:09:25 -0400 Subject: [PATCH 1/2] [bug] Fix FILES sort and path provider issue The FILES metadata is supplementary, but was logging a warning while generating Ada client that FILES couldn't be written. An exception was being thrown because Path was being reported as two different "types of Path". One would be reported as mac file, while the other was reported as a unix file. The fix here is to disconnect path details from the underlying file system provider by creating a new Path based on the file's absolute path. This change also fixes sorting so it works alphabetically in ascending order. --- .../org/openapitools/codegen/DefaultGenerator.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 24f407c08a55..e10000f981d7 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 @@ -1433,6 +1433,11 @@ private void generateVersionMetadata(List files) { } } + private Path absPath(File input) { + // intentionally creates a new absolute path instance, disconnected from underlying FileSystem provider of File + return java.nio.file.Paths.get(input.getAbsolutePath()); + } + /** * Generates a file at .openapi-generator/FILES to track the files created by the user's latest run. * This is ideal for CI and regeneration of code without stale/unused files from older generations. @@ -1443,7 +1448,7 @@ private void generateFilesMetadata(List files) { if (generateMetadata) { try { StringBuilder sb = new StringBuilder(); - File outDir = new File(this.config.getOutputDir()); + Path outDir = absPath(new File(this.config.getOutputDir())); List filesToSort = new ArrayList<>(); @@ -1452,7 +1457,7 @@ private void generateFilesMetadata(List files) { // We have seen NPE on CI for getPath() returning null, so guard against this (to be fixed in 5.0 template management refactor) //noinspection ConstantConditions if (f != null && f.getPath() != null) { - filesToSort.add(f); + filesToSort.add(outDir.relativize(absPath(f)).normalize().toFile()); } }); @@ -1461,13 +1466,12 @@ private void generateFilesMetadata(List files) { String relativeMeta = METADATA_DIR + "/VERSION"; filesToSort.sort(PathFileComparator.PATH_COMPARATOR); filesToSort.forEach(f -> { - 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 // 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, "." + File.separator), File.separator); + String relativePath = removeStart(removeStart(f.toString(), "." + File.separator), File.separator); if (File.separator.equals("\\")) { // ensure that windows outputs same FILES format relativePath = relativePath.replace(File.separator, "/"); From 6e8991da2abe5b794272f8eb7f2bc9574bc56b82 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 15 Oct 2020 22:14:27 -0400 Subject: [PATCH 2/2] [samples] Regenerate --- .../petstore/ada/.openapi-generator/FILES | 8 +++++ .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../.openapi-generator/FILES | 2 +- .../builds/default/.openapi-generator/FILES | 2 +- .../builds/with-npm/.openapi-generator/FILES | 2 +- .../default/.openapi-generator/FILES | 2 +- .../npm/.openapi-generator/FILES | 2 +- .../.openapi-generator/FILES | 30 +++++++++---------- 19 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 samples/client/petstore/ada/.openapi-generator/FILES diff --git a/samples/client/petstore/ada/.openapi-generator/FILES b/samples/client/petstore/ada/.openapi-generator/FILES new file mode 100644 index 000000000000..476daf7c2ffe --- /dev/null +++ b/samples/client/petstore/ada/.openapi-generator/FILES @@ -0,0 +1,8 @@ +config.gpr +src/client/samples-petstore-clients.adb +src/client/samples-petstore-clients.ads +src/model/samples-petstore-models.adb +src/model/samples-petstore-models.ads +src/samples-petstore-client.adb +src/samples-petstore.ads +src/samples.ads 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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.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 7f11560dda7f..7f8ebffb302f 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 @@ -11,9 +11,9 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.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 d85eeefc6f26..5db7bd763695 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 @@ -11,11 +11,11 @@ git_push.sh index.ts model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts ng-package.json package.json tsconfig.json diff --git a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES index ff52c7c5b2b8..78263e8c1901 100644 --- a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES @@ -7,8 +7,8 @@ api/userApi.ts git_push.sh model/apiResponse.ts model/category.ts +model/models.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 d24a1934784b..e69a0c8e226f 100644 --- a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES @@ -7,10 +7,10 @@ api/userApi.ts git_push.sh model/apiResponse.ts model/category.ts +model/models.ts model/order.ts model/pet.ts model/tag.ts model/user.ts -model/models.ts package.json tsconfig.json 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 8c41d6e8cf56..52c184ea4ba4 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES @@ -1,3 +1,7 @@ +.coveralls.yml +.gitignore +.php_cs.dist +.travis.yml Api/ApiServer.php Api/PetApiInterface.php Api/StoreApiInterface.php @@ -6,27 +10,14 @@ Controller/Controller.php Controller/PetController.php Controller/StoreController.php Controller/UserController.php +DependencyInjection/Compiler/OpenAPIServerApiPass.php +DependencyInjection/OpenAPIServerExtension.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 -.travis.yml -DependencyInjection/Compiler/OpenAPIServerApiPass.php -DependencyInjection/OpenAPIServerExtension.php OpenAPIServerBundle.php README.md Resources/config/routing.yml @@ -40,6 +31,15 @@ Resources/docs/Model/Order.md Resources/docs/Model/Pet.md Resources/docs/Model/Tag.md Resources/docs/Model/User.md +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 autoload.php composer.json git_push.sh