I am following a design-first approach to building a REST API, on a Java/Spring MVC stack.
I have a hand-written Swagger schema that I want to validate in my Maven build, and I want that build to fail if the schema doesn't conform to the Swagger schema specification.
I've tried doing this by using swagger-codegen
to generate some static documentation; but 1) it's not catching errors that swagger-editor
catches; and 2) the output isn't great (but that's beside the point ;-)).
Has anybody solved this problem satisfactorily themselves?
You can create an extra step in your Maven build system to validate the Swagger document against the Swagger 2.0 Schema.
I created a sample Maven project that validates the swagger JSON documents under /src/main/resources/swagger
.
You can clone the project here: https://github.com/navidsh/maven.swagger.validator