Micronaut-core: Compile Time OpenAPI Documentation Support

Created on 24 May 2018  路  8Comments  路  Source: micronaut-projects/micronaut-core

Micronaut should at compile time generate OpenAPI doc

in progress enhancement

Most helpful comment

@hampsterx For Kotlin the openapi dependency has to be in the kapt scope

All 8 comments

Great work gang. Is it possible to add docs how to bridge the generated yml to being available at an endpoint via http? I can manually copy it and probably render it, but I would bet an endpoint could be auto registered when using the new application level annotation.

Swagger UI can simply be embedded via an HTML page pointing to the YAML https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md

awesome but sorry noob question but should this be working for kotlin?

using master (934a50411) + openapi/swagger annotationProcessor/compile deps + annotation on main.

@OpenAPIDefinition(info = Info(title="test"))


./gradlew build --info
```

builds fine but no yaml in builds/generated dir :(

@hampsterx yes it should work for Kotlin

@graemerocher I understand using the ui, but I was referring to how to get the yaml to render as a web page. Copying the output yaml and building a controller method to expose etc. That was what I was asking about. Having an endpoint that auto exposes the yaml when using the @openapi annotation etc.

It is a simple matter of placing the generated YAML in src/main/resources/public/swagger and configuring it to be exposed as a static resource as per https://docs.micronaut.io/latest/guide/index.html#staticResources

I don't believe a backing controller would be required and I am not sure we should be making the choice to expose the YAML for the user, it would be a step the user would have to choose to undertake

@hampsterx For Kotlin the openapi dependency has to be in the kapt scope

Is there an example micronaut+kotlin+swagger.json/yaml ?

Was this page helpful?
0 / 5 - 0 ratings