Not able to parse an OpenAPI 3.0.0 specification file using on k8 setup using OpenApiParser

Viewed 50

I have a Spring Boot project and I have an OpenAPI 3.0.0 YAML file in the resource folder.

To parse my YAML file, I am constructing a URL and using OpenApiParser as follows:

URL url = Resources.getResource(MyFile.yaml) //from com.google.common.io
 
OpenApi3 openApi3 = (OpenApi3) new OpenApiParser().parse(url);

When running from my local IntelliJ IDEA, url comes as follows and parsing is working fine:

"file:/C:/git/top_level_project/my_folder/my_project/build/resources/main/MyFile.yaml"

but when my project is being deployed at k8 setup, url comes as follows and parsing is getting failed:

"jar:file:some_image_name.jar!/BOOT-INF/lib/my_folder-0.1.0-beta.0.149+20220910T185040Z-plain.jar!/MyFile.yaml"

I also tried the following ways to construct the URL but getting the same URL on k8 setup and OpenAPI parsing getting failed due to the incorrect path.

URL url1 =  this.getClass().getResource("/" + MyFile.yaml); //from java.lang
 
URL url2 = this.getClass().getClassLoader().getResource(MyFile.yaml));
0 Answers
Related