enunciate
enunciate copied to clipboard
Support multiple enunciate configuration without re-scanning the code
I'm currently using enunciate mainly to be able to use the generated swagger.json
file that I process myself to create the HTML document for my APIs.
Using the maven plugin, I have multiple executions:
<plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<configuration>
<docsDir>${project.build.directory}/documentation/generated</docsDir>
<sourcepath-includes>
<include>
<groupId>org.springframework.hateoas</groupId>
</include>
</sourcepath-includes>
<sources>
<source>${project.build.directory}/generated-sources/delombok</source>
</sources>
</configuration>
<executions>
<execution>
<id>api-A</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>src/main/resources/enunciate/enunciate-api-A.xml</configFile>
<docsSubdir>api-A-enunciate</docsSubdir>
</configuration>
</execution>
<execution>
<id>api-B</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configFile>src/main/resources/enunciate/enunciate-api-B.xml</configFile>
<docsSubdir>api-B-enunciate</docsSubdir>
</configuration>
</execution>
</executions>
</plugin>
I was wondering if it would be feasible to scan the code only once in order to produce different swagger.json
file?
Currently it can take 10s to scan the code and I have more than 30 different enunciate configurations on the same code.
The problem is that the scanning is also configured via enunciate.xml
, so there's currently no way to do this.
Sorry!
Actually, instead of closing this, I'll turn this into an enhancement request seeking a sponsor.
What would be the best way to approach this in order to make Enunciate support this use case?
It would be a pretty significant shift in the architecture. We'd have to split the scanning and compilation away from the generating engine. We'd probably need two separate configuration files, one for the scanning/compilation and another for the generating engine. We'd have to figure out how to iterate over multiple generation steps.
The work would mostly be done in Enunciate.java
.
Instead this kind of process:
Enunciate enunciate = new Enunciate();
enunciate.setModules(modules);
enunciate.setBuildDir(buildDir);
enunciate.setConfig(config);
enunciate.setSourceFiles(sourceFiles);
enunciate.setClasspath(classpath);
enunciate.run();
It would need to look like this kind of process:
Enunciate enunciate = new Enunciate();
enunciate.setCompileConfig(compileConfig);
enunciate.setSourceFiles(sourceFiles);
enunciate.setClasspath(classpath);
enunciate.run(() -> {
EnunciateRun[] runs = ...;
for (EnunciateRun run : runs) {
run.setModules(modules);
run.setBuildDir(buildDir);
run.setConfig(config);
run.execute();
}
})