Hey all,
I'm using the openapi spec with vertx 3.6.3. In the spec, I refer to other yaml files.
SomeType:
type: object
description: some record
properties:
core:
type: string
enum: ['type1', 'type2']
example: 'type1'
type1:
$ref: "./spec/type1.yaml#/Type1"
type2:
$ref: "./spec/type2.yaml#/Type2"
All works fine when I run it locally from my IDE (Intellij). However, whenever I build a fat jar (or a runtime), the included files are not found:
WARNING: Exception while reading:: java.lang.RuntimeException: Unable to load RELATIVE ref: ./spec/another.yaml path: /home/<some path>/swaggerroot
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:183)
at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:118)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:49)
at io.swagger.v3.parser.processors.SchemaProcessor.processReferenceSchema(SchemaProcessor.java:201)
at io.swagger.v3.parser.processors.SchemaProcessor.processPropertySchema(SchemaProcessor.java:102)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchemaType(SchemaProcessor.java:53)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchema(SchemaProcessor.java:38)
at io.swagger.v3.parser.processors.ComponentsProcessor.processSchemas(ComponentsProcessor.java:222)
at io.swagger.v3.parser.processors.ComponentsProcessor.processComponents(ComponentsProcessor.java:72)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:50)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:53)
at io.vertx.ext.web.api.contract.openapi3.OpenAPI3RouterFactory.lambda$create$1(OpenAPI3RouterFactory.java:164)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:272)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: Could not find ./spec/another.yaml on the classpath
at io.swagger.v3.parser.util.ClasspathHelper.loadFileFromClasspath(ClasspathHelper.java:31)
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:177)
at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:118)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:49)
at io.swagger.v3.parser.processors.SchemaProcessor.processReferenceSchema(SchemaProcessor.java:201)
at io.swagger.v3.parser.processors.SchemaProcessor.processPropertySchema(SchemaProcessor.java:102)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchemaType(SchemaProcessor.java:53)
at io.swagger.v3.parser.processors.SchemaProcessor.processSchema(SchemaProcessor.java:38)
at io.swagger.v3.parser.processors.ComponentsProcessor.processSchemas(ComponentsProcessor.java:222)
at io.swagger.v3.parser.processors.ComponentsProcessor.processComponents(ComponentsProcessor.java:72)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:50)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:53)
at io.vertx.ext.web.api.contract.openapi3.OpenAPI3RouterFactory.lambda$create$1(OpenAPI3RouterFactory.java:164)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:272)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
How can I make relative paths work properly with fat jars/runtime builds?
Thx, Kurt