Add springdoc-openapi Gradle + Maven generator plugins - #85
Open
vpelikh wants to merge 2 commits into
Open
Conversation
Generate the OpenAPI JSON/YAML spec from a Spring Boot app without keeping a web
server running, supporting WebFlux (reactive) and WebMvc (servlet).
- springdoc-openapi-generator-worker: shared thin worker whose entry point
GeneratorWorkerMain detects the app's web stack from the fork classpath and
dispatches to GeneratorWorkerWebFlux (REACTIVE, no port bound via a no-op
ReactiveWebServerFactory) or GeneratorWorkerWebMvc (SERVLET, ephemeral port 0,
shut down immediately). Writes the JSON/YAML atomically and fails fast on an
unsupported format.
- springdoc-openapi-gradle-plugin: standalone Gradle plugin exposing
openApiGenerate { mainClass, outputDir, outputFileName, format, timeoutSeconds,
systemProperties, skip }. Forks the worker with the Java toolchain's launcher
and a configurable fork timeout.
- springdoc-openapi-maven-plugin: 'generate' Mojo (springdoc.skip supported)
that resolves the worker and transitive deps via Aether and forks it against
the project's runtime classpath.
- systemProperties escape hatch for infra-dependent apps (e.g. JPA/Hibernate)
via a generation-time profile/overrides.
- The Gradle fork classpath carries only the worker jar (matching the Maven
Mojo) so a WebMvc app's servlet stack detection is never flipped by a
webflux-api safety-net; the app's own runtime classpath provides its stack.
- Registered worker and plugin in springdoc-openapi-bom; per-module gitignore.
vpelikh
force-pushed
the
feature/openapi-gradle-plugin
branch
from
August 26, 2026 17:38
c4543af to
061c7d8
Compare
vpelikh
force-pushed
the
feature/openapi-gradle-plugin
branch
from
August 26, 2026 18:58
a20d3b8 to
9398a40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two build-time generator plugins that produce an OpenAPI document for a Spring Boot application without leaving a web server running. Both plugins share a single forked-JVM worker (
springdoc-openapi-generator-worker) that boots the application context, lets springdoc-openapi build the spec, writes it to disk, and shuts the context down.io.github.vpelikh.springdoc-openapi-gradle-pluginskipflag, and YAML output (4 tests).springdoc-openapi-maven-pluginmaven-invoker-pluginintegration tests (generate,generate-webmvc,generate-yaml,generate-skip,generate-jpa).springdoc-openapi-generator-workerReactiveWebServerFactory(fully serverless) or a servlet context on an ephemeral port, writes the spec, then exits.The Gradle plugin is wired into CI (build + tests) and configured for publishing.
Changes
New modules
springdoc-openapi-generator-worker/— shared forked-JVM worker used by both plugins. Detects the target app's stack from its classpath and dispatches to a WebFlux or WebMvc generator.springdoc-openapi-gradle-plugin/— Gradle plugin (generateOpenApitask).springdoc-openapi-maven-plugin/— Maven Mojo (springdoc:generate-openapi).CI / publishing (Gradle plugin)
.github/workflows/build.yml— addsSetup Gradleand an extendedBuild with Maven and Gradlestep that builds and tests the Gradle plugin after the Maven install (which populatesmavenLocalwith the SNAPSHOT artifacts the functional tests resolve)..github/workflows/release.yml— addsSetup Gradleand aPublish Gradle pluginstep that runs./gradlew publishPluginswithGRADLE_PUBLISH_KEY/GRADLE_PUBLISH_SECRET.springdoc-openapi-gradle-plugin/build.gradle—java-gradle-plugin+com.gradle.plugin-publish+maven-publish; plugin id, website/vcsUrl, displayName, description, and tags configured.springdoc-openapi-gradle-plugin/gradle.properties— the plugin version, kept in sync with the Maven release viaCI/prepare-release-commit.shandCI/bump-snapshot.sh.Version lifecycle
CI/prepare-release-commit.sh— also setsspringdoc-openapi-gradle-plugin/gradle.properties.CI/bump-snapshot.sh— also bumps the Gradle plugin version after a final release.Design notes
ReactiveWebServerFactory); WebMvc starts a real, short-lived container because the servlet model requires aServletContext.Testing
./gradlew :springdoc-openapi-gradle-plugin:build./mvnw install(runs themaven-invoker-pluginITs).build.ymlruns the full Maven build followed by the Gradle plugin build/test on Java 17 and 25.Notes / follow-ups
io.github.vpelikh.springdoc-openapi-gradle-plugin(not the upstreamorg.springdoc, which is not controlled by this fork).GRADLE_PUBLISH_KEY/GRADLE_PUBLISH_SECRETGitHub secrets to be present for the release-timepublishPluginsstep to succeed.5.0.6-SNAPSHOTand inherits the existing release/bump workflow.Checklist
mvnw install)