jiekang / thermostat-web-api

Git mirror of icedtea.classpath.org/people/jkang/thermostat-web-api/
2 stars 2 forks source link

swagger docs autogeneration #1

Closed thescouser89 closed 7 years ago

thescouser89 commented 7 years ago

This commit adds the ability to autogenerate swagger docs (but really swagger.json) by scanning through the JAX-RS classes (from package 'com.redhat.thermostat.server.core.internal.web.http') and using the JAX-RS annotations to generate the swagger definitions.

The swagger generated is found in '/swagger.json' swagger1

This feature is activated when the 'SWAGGER_UI_ENABLED' feature is switched on.

To be able to activate the Swagger generation, I thought that it was necessary to extend the ResourceConfig class to be able to create a new BeanConfig, which is necessary to configure Swagger. In the future, if a web.xml file is used instead, this code could be removed.

The relevant document was used to configure Swagger with Jersey for auto-swagger doc generation: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5

The root web path for the swagger's index.html is also moved from '/index.html' to '/apidocs' to avoid any naming collisions that might happen. swagger2

thescouser89 commented 7 years ago

@jiekang ❤️ 💟 😍