java OpeApiPlugin - No API definition provided - withDefinitionConfiguration BiConsumer does not get called

27 Views Asked by At

The overall problem is that my swagger-ui (now OpenAPi) does not render the swagger-ui page with all the api-endpoints. It errors with "No API definition provided".

My eclipse gradle project written in java uses Javalin as the webservice. We recently moved to a more current version of OpenApi (using OpenApiPlugin). However, now my code running in eclipse does not call the withDefinitionConfiguration BiConsumer passed in. All I can think of is that there is some bug in how eclipse handles the call to the kotlin compiled OpenApiPlugin jar. Any ideas?

Here is the relavent code block:

    app = Javalin.create(config -> {

        config.registerPlugin(new OpenApiPlugin(openApiConfig ->
        {
            LOGGER.debug("###################### registerPlugin consumer called");
            openApiConfig
                .withDocumentationPath(PATH_PREFIX+DOC_PATH)
                .withRoles(WebRole.ALL_ROLES)
                .withDefinitionConfiguration((version, definitionConfiguration) ->
                {
                    LOGGER.debug("###################### withDefinition BiConsumer (is this called? - not yet - why not?)");
                    definitionConfiguration
                        .withServer(openApiServer -> {
                            openApiServer.setUrl(SERVER_URL+PATH_PREFIX);
                        })
                        .withInfo(openApiInfo -> {
                            openApiInfo.setDescription("My Description");
                            openApiInfo.setVersion("1.1");
                        });
                }
        );
    })
                );
    
        config.registerPlugin(new SwaggerPlugin(swaggerConfiguration -> {
            swaggerConfiguration.setDocumentationPath(PATH_PREFIX+DOC_PATH);
            swaggerConfiguration.setUiPath(PATH_PREFIX+SWAGGER_PATH);
        }));

        for (JsonSchemaResource generatedJsonSchema : new JsonSchemaLoader().loadGeneratedSchemes()) {
            System.out.println(generatedJsonSchema.getName());
            System.out.println(generatedJsonSchema.getContentAsString());
        }
        
    });
0

There are 0 best solutions below