kbuntrock / openapi-maven-plugin

Generate openapi documentation for SpringMVC or JaxRS/JakartaRS projects.
https://kbuntrock.github.io/openapi-maven-plugin/
MIT License
16 stars 12 forks source link

Suggestion: simplify configuration by allowing only one "api" by execution #167

Closed murdos closed 1 week ago

murdos commented 1 week ago

The plugin configuration allows to handle multiple generated openapi documentation, but this makes the configuration more complex and harder to apprehend. However, in most case you only need one generated documentation.

So what about merging <apiConfiguration> and <api>?

If you really need multiple generated openapi documentations, you can do it in the maven way, by configuring multiple executions:

<plugin>
    <groupId>io.github.kbuntrock</groupId>
    <artifactId>openapi-maven-plugin</artifactId>
    <version>0.0.18</version>
    <executions>
        <execution>
            <id>first-api</id>
            <goals>
                <goal>documentation</goal>
            </goals>
            <configuration>
               <!-- define here filename, location, ... for the first documentation -->
                    <locations>
                      <location>io.github.kbuntrock.sample.endpoint</location>
                  </locations>
                  <filename>first.yml</filename>
            </configuration>
        </execution>
        <execution>
            <id>second-api</id>
            <goals>
                <goal>documentation</goal>
            </goals>
            <configuration>
               <!-- define here filename, location, ... for the second documentation -->
                    <locations>
                      <location>io.github.kbuntrock.second.endpoint</location>
                  </locations>
                  <filename>second.yml</filename>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <!-- Here you have the common configuration -->
         <library>SPRING_MVC</library>
    </configuration>
</plugin>
murdos commented 1 week ago

NB: I'm willing to help make the changes, if we agree on it :)

kbuntrock commented 1 week ago

I'm not so keen for this since it will force users to duplicate some common configurations when they are using this functionality (some projects I know are for exemple filtering endpoints by versions to produce multiple documents). It will also slow down the process since javadoc reading will be executed multiple times.

As I see it, this functionality can almost be invisible to end users, and is only a small inconvenience for developers since everything is merged in the API configuration class.

But I ear the problem. My first idea could be to introduce the missing attributes to the common section, so it can be a "standalone" config. Meaning you can define the "locations" and the filename in the common section, and never use the "APIs" sections. And update the quick start documentation to the new simplest way.

What do you think of that?

murdos commented 1 week ago

The intent was also to simplify the plugin code, whereas keeping both behaviors might make it more complex :) I also had not realized this would imply scanning javadoc multiple times. So let's keep it as it is!