sdaschner / jaxrs-analyzer

Creates REST documentation for JAX-RS projects
Apache License 2.0
319 stars 101 forks source link

make it easy to extend swaggerbackend #153

Open rmannibucau opened 6 years ago

rmannibucau commented 6 years ago

the need is to be able to implement its own swagger backend to add custom extensions in the model so it requires classes to become public and method protected

Some rational behind it: to add x-restlet swagger extension i needed to fork the whole swagger backend (https://github.com/rmannibucau/jaxrs-analyzer-extension/blob/master/src/main/java/com/github/rmannibucau/jaxrsanalyzer/backend/EnrichedSwaggerBackend.java) which is a pain. Enhancements are:

  1. bytes handling https://github.com/rmannibucau/jaxrs-analyzer-extension/blob/master/src/main/java/com/github/rmannibucau/jaxrsanalyzer/backend/EnrichedSwaggerBackend.java#L399,
  2. section handling https://github.com/rmannibucau/jaxrs-analyzer-extension/blob/master/src/main/java/com/github/rmannibucau/jaxrsanalyzer/backend/EnrichedSwaggerBackend.java#L422 + https://github.com/rmannibucau/jaxrs-analyzer-extension/blob/master/src/main/java/com/github/rmannibucau/jaxrsanalyzer/backend/EnrichedSwaggerBackend.java#L129
sdaschner commented 6 years ago

Hmm.. what would you suggest? Having an SPI would be the most flexible option I guess.

rmannibucau commented 6 years ago

There is already a spi in the analyzer (see the issue in mvn plugin) but methods should be protected to let it be useful

sdaschner commented 6 years ago

I see (sorry for the late response, once again :))

So, a solution would be to modularize the Swagger backend impl (so the methods fits the swagger concepts) to make it extendable, while doing the "hard work" in the base API class?

rmannibucau commented 6 years ago

Sounds good as the generic solution.

Side note: supporting some widely spread extensions can be good too (restlet, tomitribe, etc...)