Vertx:有效的Yaml在OpenAPI3RouterFactory中导致空指针异常

时间:2018-09-25 14:28:32

标签: swagger vert.x openapi

我有一个Yaml:

openapi: 3.0.0
info:
  version: "1.0-Snapshot"
  title: "Hub-Interface v2.5"

我无法共享完整文件,但是当我将YAML粘贴到https://editor.swagger.io/

上时,它就可以正确解析并显示YAML。

但是当我在下面调用getRouter()时,会导致异常

... 



OpenAPI3RouterFactory.create(vertx, "CoD_Hub-interface-description.yaml", ar -> {

                        // The router factory instantiation could fail
                        if (!ar.succeeded()) {
                            log.error("===== OpenAPI3RouterFactory create failed in APIServerVerticle", ar.cause());
                            startFuture.fail(ar.cause());
                            return;
                        }
                        OpenAPI3RouterFactory factory = ar.result();

   // ...

                    factory.addHandlerByOperationId("receive", this::receive);
                    factory.addSecurityHandler("basicAuth", this::handleSecurity);
                    factory.addSecurityHandler("client", this::handleSecurity);
                    Router router1 = factory.getRouter();

我得到一个空指针异常:

2018-09-25 16:15:30,667 [vert.x-eventloop-thread-6] WARN  com.networknt.schema.JsonMetaSchema - Unknown keyword example - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword 
Sep 25, 2018 4:15:30 PM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
java.lang.NullPointerException
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:214)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.replaceRef(OpenApi3Utils.java:267)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:215)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:236)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.generateSanitizedJsonSchemaNode(OpenApi3Utils.java:209)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.parseRequestBody(OpenAPI3RequestValidationHandlerImpl.java:473)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.parseOperationSpec(OpenAPI3RequestValidationHandlerImpl.java:104)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.<init>(OpenAPI3RequestValidationHandlerImpl.java:87)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RouterFactoryImpl.getRouter(OpenAPI3RouterFactoryImpl.java:229)
    at com.vulog.vwgateway.VWAPIServerVerticle.lambda$start$3(VWAPIServerVerticle.java:71)

我的.yaml文件包含示例,该示例应该有效。但是即使没有它们,我也会得到一个空指针异常而没有太多信息:

Sep 25, 2018 4:25:16 PM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
java.lang.NullPointerException
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:214)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.replaceRef(OpenApi3Utils.java:267)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:215)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.walkAndSolve(OpenApi3Utils.java:236)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenApi3Utils.generateSanitizedJsonSchemaNode(OpenApi3Utils.java:209)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.parseRequestBody(OpenAPI3RequestValidationHandlerImpl.java:473)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.parseOperationSpec(OpenAPI3RequestValidationHandlerImpl.java:104)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl.<init>(OpenAPI3RequestValidationHandlerImpl.java:87)
    at io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RouterFactoryImpl.getRouter(OpenAPI3RouterFactoryImpl.java:229)
    at com.vulog.vwgateway.VWAPIServerVerticle.lambda$start$3(VWAPIServerVerticle.java:71)

0 个答案:

没有答案