Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegate resolving of relative URLs to Java framework, instead of sol…
…ving that in custom code. ## Repro ```Java String rootPath = "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-02-01/storage.json"; String relativePath = "../../../../../common-types/resource-management/v1/types.json"; String expected="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/common-types/resource-management/v1/types.json"; System.out.println(io.swagger.parser.util.RefUtils.buildUrl(rootPath, relativePath)); ``` results in an `ArrayIndexOutOfBoundsException`: ```txt Exception in thread "main" java.lang.RuntimeException: Unable to load RELATIVE ref: ../../../../../common-types/resource-management/v1/types.json path:https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-02-01/storage.json at io.swagger.parser.util.RefUtils.readExternalUrlRef(RefUtils.java:68) at io.swagger.parser.ResolverCache.loadRef(ResolverCache.java:116) at io.swagger.parser.processors.ParameterProcessor.processParameters(ParameterProcessor.java:37) at io.swagger.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:26) at io.swagger.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:101) at io.swagger.parser.SwaggerResolver.resolve(SwaggerResolver.java:50) at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:71) at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:431) at io.swagger.codegen.cmd.Generate.run(Generate.java:283) at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35) Caused by: java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at io.swagger.parser.util.RefUtils.buildUrl(RefUtils.java:108) at io.swagger.parser.util.RefUtils.readExternalUrlRef(RefUtils.java:63) ``` I experienced that when using the codegen CLI: ```bash java -jar swagger-codegen-cli.jar generate \ -l elixir \ -i "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2018-02-01/storage.json" ```
- Loading branch information