User Tools

Site Tools


dropwizard

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
dropwizard [2015/02/12 12:05]
mihael
dropwizard [2015/02/12 16:04]
mihael
Line 84: Line 84:
  
 If a field should be ignored during the serialization process the annotation ''​@JsonIgnore''​ can be used or the field can be marked as ''​transient''​. If a field should be ignored during the serialization process the annotation ''​@JsonIgnore''​ can be used or the field can be marked as ''​transient''​.
 +
 +
 +===== Swagger =====
 +Swagger can be used to document the REST services registered the dropwizard instance.
 +
 +==== Add Maven Dependency ====
 +<sxh xml>
 +<​dependency>​
 +    <​groupId>​io.federecio</​groupId>​
 +    <​artifactId>​dropwizard-swagger</​artifactId>​
 +    <​version>​0.5.2</​version>​
 +</​dependency>​
 +</​sxh>​
 +
 +==== Register Swagger UI ====
 +<sxh java; title = In Application class>
 +private final SwaggerDropwizard swaggerDropwizard = new SwaggerDropwizard();​
 +
 +@Override
 +public void initialize(Bootstrap<​TestConfiguration>​ bootstrap) {
 +    ...
 +    swaggerDropwizard.onInitialize(bootstrap);​
 +}
 +
 +@Override
 +public void run(TestConfiguration configuration,​ Environment environment) throws Exception {
 +    ...
 +    swaggerDropwizard.onRun(configuration,​ environment);​
 +}
 +</​sxh>​
 +
 +==== Annotate Resources ====
 +Swagger only scans resources which have an @Api annotation on them. Resources need to be annotated to be listed by swagger.
 +
 +==== Annotate Methods ====
 +At least one method must be annotated for the resource to be visible for swagger.
 +
 +
 +==== Links ====
 +  * https://​github.com/​federecio/​dropwizard-swagger
 +  * https://​github.com/​swagger-api/​swagger-core/​wiki/​JavaDropwizard-Quickstart
  
  
 {{tag>​devel java}} {{tag>​devel java}}
dropwizard.txt ยท Last modified: 2017/07/12 14:51 by mihael