A custom SpecFilter for the OpenAPI/Swagger.
Some API implementations, like CDAP Netty, for which this filter was originally written, requires method signatures like this:
public void concatenate(HttpRequest req, HttpResponder res, @PathParam("str1") String str1, @PathParam("str2") String str2)
This results in the OpenAPI tools to register HttpRequest
and HttpResponder
as schemas in the resulting API spec.
The Custom SpecFilter removes these entries from the method signatures before the spec is written.
When adding and removing API calls, the OpenAPI spec is sorted in whatever internal representation the plugin has. This means that when you add new things, it'll also move things around seemingly at random. If your spec is checked into source control, this can make for annoying diffs. The Custom SpecFilter makes sure everything is sorted before writing the spec.
Include the Custom SpecFilter as a normal dependency and configure your the filterClass
property of your respective
plugin:
resolve {
filterClass = "com.autonomouslogic.customspecfilter.CustomSpecFilter"
}
<project>
<build>
<plugins>
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<configuration>
<filterClass>com.autonomouslogic.customspecfilter.CustomSpecFilter</filterClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
A number of schema names are removed by default.
To override the default and customise which schemas are removed, create a file in the root of your project called customspecfilter.json
:
{
"filteredSchemas": [
"BodyConsumer",
"DecoderResult",
"HttpMethod",
"HttpRequest",
"FullHttpRequest",
"HttpVersion",
"HttpResponder"
]
}
Custom SpecFilter follows semantic versioning.
Custom SpecFilter is licensed under the MIT-0 license.
Type | Status |
---|---|
LGTM | |
CodeClimate | |
SonarCloud | |
Libraries.io | |
Snyk | |
Synatype Lift | link |