Skip to content

Swagger plugin doesn't work for external openapi spec #231

@mathijs81

Description

@mathijs81

Actual behavior (the bug)
I have a javalin server that has an API and an openapi specification, but no javalin-openapi annotations. (We actually use spec-first and generate the code with openapi-generator.tech which has a javalin6 generator as part of kotlin-server).

I serve the generated openapi.yaml under /openapi and register config.registerPlugin(SwaggerPlugin())

The swagger UI doesn't load under /swagger and says no API found.

Expected behavior
Swagger UI working under /swagger

To Reproduce
Set up project with just swagger plugin and a server openapi file.

Additional context
I found a workaround. The problematic code is

where OpenApiLoader is asked to provide all API versions.
I added a resource file openapi-plugin/.index with just the word default in it and then everything works.
It would be nice if the SwaggerPlugin config could accept the versions of the API (and maybe revert back to default if the openapi plugin is not active) so that this works more easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions