springdoc / springdoc-openapi-maven-plugin

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
141 stars 37 forks source link

Actual build-time capability without a running server #55

Closed johnament closed 1 year ago

johnament commented 1 year ago

We love springdoc. One thing we find a little annoying though is that to generate the documentation, the server must be running. Essentially the only thing the maven plugin does is calls the URL for the OpenAPI output and persists it to disk. While it checks the box that we can generate the documentation at build time, the overhead of needing to start the server in a dedicated phase of the build is a little much. So a couple of questions:

  1. Is generating the documentation at build time even feasible without the running application? E.g. can the maven mojo somehow look at the annotations to get this data or does that become too much of a dedicated maven solution?
  2. If doing it at build time by looking at the various annotations doesn't work, is it feasible to tie in the call at a different phase? E.g. in https://springdoc.org/#maven-plugin you have the user start/stop the spring boot server but I'm wondering if that can be done inside a test as well so that we don't need a dedicated step to do it?
philsturgeon commented 1 year ago

Another benefit for build-time OpenAPI generation is that seucirty filters can get in the way. I've spent a few hours trying to get an existing application to whitelist these endpoints, and its complicated by there being a bunch of security filters already.

ataraxus commented 1 year ago

I tend to use https://github.com/kongchen/swagger-maven-plugin but it is a bit outdatedn nowadays regarding OpenApi standard and has no gradle support.

It tried this several times and I wonder how well other applications are designed so that one could effort to support starting up the application just for the sake of creating the openapi.json. I always stumble upon some runtime depencies causing trouble in such minimal profiles.

bnasslahsen commented 1 year ago

There are no plans for this feature.

If you feel it interesting for the community, please feel free to propose a PR.