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

Parser does not handle reference in external file #299

Closed
abhijith-prabhakar opened this issue Sep 13, 2016 · 7 comments
Closed

Parser does not handle reference in external file #299

abhijith-prabhakar opened this issue Sep 13, 2016 · 7 comments
Milestone

Comments

@abhijith-prabhakar
Copy link

I am using swagger-codegen(v2.2.1) for java-jaxrs and my file structure is given below

|____static
| |____json-schema
| | |____error.json
| | |____error_details.json
| | |____link_description.json
| |____swagger.json

swagger.json is referring to error.json which in turn is referring to error_details.json and link_description.json.

In error.json if I provide reference "$ref":"error_details.json" swagger codegen cannot find error_details.json and is not working. But, if I provide reference as "$ref":"./json-schema/link_description.json" (relative to swagger.json) then codegen works fine, but swagger-ui breaks.

@diegode
Copy link

diegode commented Sep 14, 2016

@abhijith-prabhakar does it work if you put "./error_details.json" instead of "error_details.json"?

@abhijith-prabhakar
Copy link
Author

abhijith-prabhakar commented Sep 15, 2016

Yes, I have tried it. It gives below error

io.swagger:swagger-codegen-maven-plugin:2.2.1:generate failed: Unable to load RELATIVE ref: ./error_details.json
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
....
Caused by: java.lang.RuntimeException: Unable to load RELATIVE ref: ./error_details.json
        at io.swagger.parser.util.RefUtils.readExternalRef(RefUtils.java:140)
        at io.swagger.parser.ResolverCache.loadRef(ResolverCache.java:96)
        at io.swagger.parser.processors.ExternalRefProcessor.processRefToExternalDefinition(ExternalRefProcessor.java:30)
        at io.swagger.parser.processors.PropertyProcessor.processRefProperty(PropertyProcessor.java:33)
        at io.swagger.parser.processors.PropertyProcessor.processProperty(PropertyProcessor.java:21)
        at io.swagger.parser.processors.PropertyProcessor.processArrayProperty(PropertyProcessor.java:51)
        at io.swagger.parser.processors.PropertyProcessor.processProperty(PropertyProcessor.java:23)
        at io.swagger.parser.processors.ModelProcessor.processModelImpl(ModelProcessor.java:53)
        at io.swagger.parser.processors.ModelProcessor.processModel(ModelProcessor.java:39)
        at io.swagger.parser.processors.DefinitionsProcessor.processDefinitions(DefinitionsProcessor.java:40)
        at io.swagger.parser.SwaggerResolver.resolve(SwaggerResolver.java:41)
        at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:66)
        at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:390)
        at io.swagger.codegen.plugin.CodeGenMojo.execute(CodeGenMojo.java:276)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more

@diegode
Copy link

diegode commented Sep 15, 2016

Oh, I think this was fixed in #284
This was merged to master after the last release (1.0.22).

@abhijith-prabhakar
Copy link
Author

abhijith-prabhakar commented Sep 15, 2016

I worked with Ron and Tony to test out latest snapshot of both codegen and parser. It was not fixed in those as well. It would nice if someone can double check.

@diegode
Copy link

diegode commented Sep 19, 2016

Oh, I think I understand why this is happening. This is a bug indeed.

@abhijith-prabhakar
Copy link
Author

Thanks for checking. Any ETA on the fix?

@fehguy
Copy link
Contributor

fehguy commented Oct 27, 2016

Should be fixed now.

@fehguy fehguy closed this as completed Oct 27, 2016
@fehguy fehguy modified the milestone: v1.0.23 Oct 28, 2016
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

3 participants