javalin / javalin-openapi

Annotation processor for compile-time OpenAPI & JsonSchema, with out-of-the-box support for Javalin 5.x, Swagger & ReDoc
https://github.com/javalin/javalin-openapi/wiki
Apache License 2.0
45 stars 17 forks source link

SwaggerHandler doesnt support native swagger library #205

Closed osivinyuk closed 10 months ago

osivinyuk commented 10 months ago

Hello I am using this and its not working app.get("swagger/core", new SwaggerHandler(MIDDLEWARE_CORE, "/openapi/core", "5.9.0", "", "", "", ""alpha"", ""alpha"", Collections.emptyList(), Collections.emptyList()), AppRole.ANYONE);

in your code

    val allDocumentations = OpenApiLoader()
        .loadVersions()
        .joinToString(separator = ",\n") { "{ name: '$it', url: '$publicDocumentationPath?v=$it' }" }

we have empty result

OpenApiLoader() .loadVersions()

I am using last version of javalin.

With version 5.1.4 it was working with init string app.get("swagger/core", new SwaggerHandler(MIDDLEWARE_CORE, "/openapi/core", "4.15.0", null, ""), AppRole.ANYONE);

we are using this swagger libs:

    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-core</artifactId>
        <version>2.2.18</version>
    </dependency>

    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>2.2.18</version>
    </dependency>

Could you support old SwaggerHandler constructor for our issue? Thank you

dzikoysk commented 10 months ago

SwaggerHandler is a part of internal implementation of Swagger plugin that is an enhancement built on top of the OpenApi plugin. If you don't really care about the whole OpenApi impl, you can simply copy the template:

https://github.com/javalin/javalin-openapi/blob/d85a6a8b7e1bb2327c78ca7333cae6c7a592cc93/javalin-plugins/javalin-swagger-plugin/src/main/kotlin/io/javalin/openapi/plugin/swagger/SwaggerHandler.kt#L45-L99

and adjust it to your needs. Anyway, I'll move loadVersions to constructor, so you can specify your own list here.