swagger-parser: Unable to load an OpenAPI3 spec from the classpath

In my Vert.x 3.5.0 project, I am trying to use an OpenAPI3 specification stored in src/main/resources/adjective.yaml. The problem is that the URL for the file should be classpath:adjective.yaml, but the code in the following line:

https://github.com/swagger-api/swagger-parser/blob/v2.0.0-rc1/modules/swagger-parser-v3/src/main/java/io/swagger/parser/v3/OpenAPIV3Parser.java#L112

This code assumes the URL MUST be either http or file. This will not allow from loading the spec from the classpath.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (14 by maintainers)

Most upvoted comments

There was a discussion on the Vert.x Discord about this and it has nothing to do with swagger-parser. You need to set a System Property as shown here: https://github.com/InfoSec812/budjet-vertx-hibernate-reactive-openapi/blob/main/modules/api/src/main/java/com/zanclus/BudjetLauncher.java#L6

@gracekarina I believe the (as yet unreleased) changes which @slinkydeveloper made for the 3.5.1 version of Vert.x are working perfectly and we can close this issue.

@gracekarina Unfortunately, this is work on a pre-release branch which will not be accessible for you to test unless you want to download and build vertx-web yourself. Once @slinkydeveloper and I can get it working, we will update this issue.

I’ll have a look and get back to you.

That is the exact exception caused by not being able to read the spec file. Let me tag a version and I will get back to you.

Deven Phillips Senior Consulting Engineer Red Hat, Open Innovation Labs

On Jan 26, 2018 3:32 PM, “Grace Karina Gonzalez Diaz” < notifications@github.com> wrote:

Hi @InfoSec812 https://github.com/infosec812 , I haven’t been able to run the project, it has an exception. Can you please send me the steps to reproduce the issue? thanks.

Running com.redhat.labs.insult.MainVerticleSpec INFO 26/01/18 03:18 PM: liquibase: Successfully acquired change log lock INFO 26/01/18 03:18 PM: liquibase: Successfully acquired change log lock INFO 26/01/18 03:18 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG INFO 26/01/18 03:18 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG INFO 26/01/18 03:18 PM: liquibase: Successfully released change log lock INFO 26/01/18 03:18 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG INFO 26/01/18 03:18 PM: liquibase: Successfully released change log lock [MLog-Init-Reporter] INFO com.mchange.v2.log.MLog - MLog clients using slf4j logging. [vert.x-eventloop-thread-1] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10] ene 26, 2018 3:18:45 PM io.vertx.core.impl.TaskQueue GRAVE: Caught unexpected Throwable java.lang.IllegalStateException: Result is already complete: failed at io.vertx.core.impl.FutureImpl.fail(FutureImpl.java:103) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:284) at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748)

ene 26, 2018 3:18:45 PM io.vertx.core.impl.TaskQueue GRAVE: Caught unexpected Throwable java.lang.IllegalStateException: Result is already complete: failed at io.vertx.core.impl.FutureImpl.fail(FutureImpl.java:103) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:284) at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 22.107 sec <<< FAILURE! com.redhat.labs.insult.MainVerticleSpec Time elapsed: 0 sec <<< FAILURE! Async conditions timed out after 20,00 seconds; 2 out of 3 evaluate blocks did not complete in time at spock.util.concurrent.AsyncConditions.await(AsyncConditions.java:144) at com.redhat.labs.insult.MainVerticleSpec.setupSpec(MainVerticleSpec.groovy:53)

Results :

Failed tests: com.redhat.labs.insult.MainVerticleSpec

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] microservices … SUCCESS [ 0.573 s] [INFO] adjective … SUCCESS [ 20.009 s] [INFO] noun … SUCCESS [ 12.359 s] [INFO] insult … FAILURE [ 26.471 s] [INFO] ui … SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 59.743 s [INFO] Finished at: 2018-01-26T15:19:01-05:00 [INFO] Final Memory: 66M/463M [INFO] ---------------------------------------------

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-parser/issues/637#issuecomment-360896688, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGFa-zXNv1mKFUI_dDSqQtLiYa1HdEpks5tOjZpgaJpZM4RpEx8 .

NullPointerException…

The code runs fine when the spec file is present on the local filesystem (e.g. Running in my IDE or from Maven), but once I package the whole thing up as a FatJar which includes the spec file, the parser is unable to read the file from inside of the fatjar’s classpath.

Example code available at: https://github.com/rhoar-shootout/rhoar-vertx

Thanks!