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

What is openapi.groovy? #179

Closed jflebeau closed 1 year ago

jflebeau commented 1 year ago

Getting this log on stderr: "Note: /project-path/src/main/compile/openapi.groovy", I didn't see any mention of it in the docs, just curious to know what it is.

dzikoysk commented 1 year ago

This is a special script file introduced in 5.3.0 that allows us to customize annotation processing phase:

Annotation processing API does not really provide helpful tools to access sources during compilation phase, so we're composing this location on top of the processed source files:

https://github.com/javalin/javalin-openapi/blob/e26c056f34d873dec42765d65173745ef5bc0bbe/openapi-annotation-processor/src/main/kotlin/io/javalin/openapi/processor/configuration/OpenApiPrecompileScriptingEngine.kt#L23-L33

Because this implementation is based on some assumptions related to how usually Java project looks like, I decided to log this path explicitly, so users will know where to put such script. Speaking of the available API, here's an example of various supported options:

It's kinda complex, but that's the only way to resolve some issues related to integration of 3rd party libraries with our generator.