question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative reference in external jar is resolved as a URL instead of RELATIVE

See original GitHub issue

I have a service project in which OpenAPI schemas are included via a jar file. Inside this jar file, the schema contains a relative reference to another fragment in the same jar.

These are the references:

api.json (service project)
 -> Persons.json (jar)
   -> Person.json (relative ref in same jar) 

The reference is resolvable from the service to Persons.json in the jar. However, the relative reference within the jar from Persons to Person is resolved as URL instead of RELATIVE. This generates this error:

java.net.MalformedURLException: no protocol: /Person.json

Investigation into ExternalRefProcessor shows that this code strips the leading dot off the reference from Persons to Person:

https://github.com/swagger-api/swagger-parser/blob/v.1.0.33/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java#L163

Which causes it to be treated as a URL:

https://github.com/swagger-api/swagger-parser/blob/v.1.0.33/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java#L131-L134

Simple project with steps to reproduce: https://github.com/douglasbgray/openapi-service

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
douglasbgraycommented, Mar 12, 2018

Hi @gracekarina, I checked it out and the fix in PR https://github.com/swagger-api/swagger-parser/pull/658 has resolved my issue. I have updated openapi-service and it builds correctly using the 1.0.35-snapshot version. Thanks for the quick fix!

0reactions
gracekarinacommented, Mar 14, 2018

I’ll close it no problem. It was fixed by #658

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add referenced library JAR files using relative path for ...
Right click the jar and choose copy relative path then add it to settings, click the refresh button then the added jar should...
Read more >
Description of workbook link management and storage in Excel
Workbooks links to source workbooks are created in a relative manner whenever possible. This means that the full path to the source workbook...
Read more >
RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
This specification defines the generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines...
Read more >
The Executable Jar Format - Spring
Used to resolve relative paths in loader.path . For example, given loader.path=lib , then ${loader.home}/lib is a classpath location (along with all jar...
Read more >
Use relative path for project local resources
In my use case, reference problems always occur for the following reasons: - the path to the NetBeans project has changed. Yet, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found