forked from loafle/openapi-generator-original
[core][bug] FILES is now path relative with no prefixes (#7271)
* 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. * Ensure windows outputs FILES paths in same format * Normalize FILES paths to remove relativization mid-path
This commit is contained in:
parent
a78a72b3d7
commit
da84d8e3bf
@ -60,6 +60,7 @@ import java.time.ZonedDateTime;
|
||||
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,21 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
});
|
||||
|
||||
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()).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);
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user