Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving relative URLs results in ArrayIndexOutOfBoundsException #750

Closed
chgeuer opened this issue Jul 5, 2018 · 1 comment
Closed

Comments

@chgeuer
Copy link

chgeuer commented Jul 5, 2018

Repro

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:

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:

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" 
chgeuer added a commit to chgeuer/ex_microsoft_azure_management_generator that referenced this issue Jul 6, 2018
beikov added a commit to beikov/swagger-parser that referenced this issue Apr 28, 2024
beikov added a commit to beikov/swagger-parser that referenced this issue Apr 28, 2024
@frantuma
Copy link
Member

frantuma commented May 1, 2024

fixed by #2082

@frantuma frantuma closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants