swagger-api / swagger-api/swagger-codegen
[CODEGEN-CLI] Exception while resolving external $REF
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
With version 3.0.35 of the swagger-codegen-cli there is an error when resolving external $refs. This error does not occur with version 3.0.34.
11:21:13.876 [Thread-0] WARN io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
java.lang.RuntimeException: Unable to load RELATIVE ref: foo.bar path: /path/to/openapi
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:243)
at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:150)
at io.swagger.v3.parser.processors.ParameterProcessor.processParameters(ParameterProcessor.java:89)
at io.swagger.v3.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:46)
at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:88)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:72)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:59)
at io.swagger.v3.parser.OpenAPIV3Parser.resolve(OpenAPIV3Parser.java:226)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:178)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:94)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
at io.swagger.codegen.v3.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:612)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:386)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException: Could not find foo.bar on the classpath
at io.swagger.v3.parser.util.ClasspathHelper.loadFileFromClasspath(ClasspathHelper.java:31)
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:237)
... 13 common frames omitted
11:21:13.892 [Thread-0] WARN io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
java.lang.RuntimeException: Unable to load RELATIVE ref: foo.bar path: /path/to/openapi
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:243)
....
Swagger-codegen version
swagger-codegen-cli-3.0.35.jar
Swagger declaration file content or url
parameters:
- $ref: 'parameters.yml#/foo.bar'
Command line used for generation
$ java -jar swagger-codegen-cli-3.0.35.jar generate -l openapi-yaml -i $OPENAPI_TMP/temp.yml -o ./$OPENAPI_TMP -DoutputFile=generated-openapi.yml
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at RefUtils.readExternalRef and ResolverCache.loadRef in the stack trace, then reproduce the issue with the supplied parameters.yml reference and the swagger-codegen-cli 3.0.35 command. Compare the behavior with 3.0.34; done means the relative external $ref resolves without the reported exception during generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100