I was wondering if there's a way to generate the swagger spec from an existing JAX RS annotated interface, e.g. something like this:
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface ISampleService {
@GET
@Path("sample/foobar/{foobarId}")
Foobar getFoobar(@PathParam("foobarId") String foobarId);
@PUT
@Path("sample/foobar/{foobarId}")
Foobar updateFoobar(@PathParam("foobarId") String foobarId, Foobar foobar);
}
I did find this "jaxrs analyzer" project, but it doesn't seem to recognize my interface.
Basically, I have my service defined in an interface like that, and I want to reverse-engineer the swagger spec to be able to post it so anyone else can generate (other) clients using the swagger functionality.
Preferably, the solution would just work in a maven build (plugin).
Swagger has an easy-to-follow tutorial for Jersey here.
In order for Swagger to generate a specification for your resources, you need to add the @Api
annotation at the top of your class. The available annotations are listed here, but I just use @Api
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With