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
dropwizard [2014/12/10 09:58]
mihael
dropwizard [2017/07/12 14:51] (current)
mihael [Links]
Line 1: Line 1:
 ====== Dropwizard ====== ====== Dropwizard ======
 +
 +===== HTTP =====
 +The port settings of the Jetty server can also be done via the configuration file.
 +
 +<code yaml>
 +server:
 +  applicationConnectors:​
 +      - type: http
 +        port: 18080
 +
 +  adminConnectors:​
 +      - type: http
 +        port: 18081
 +
 +</​code>​
 +
  
 ===== Logging ===== ===== Logging =====
Line 62: Line 78:
  
  
-{{tag>​devel java}}+===== Serialization ===== 
 +[[http://​wiki.fasterxml.com/​JacksonHome | Jackson]] is used for de-/​serialization of the data. 
 + 
 +''​@JsonProperty''​ is used to annotate field or method for serialization. 
 + 
 +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 dropwizard}}
dropwizard.1418205514.txt.gz · Last modified: 2014/12/10 09:58 by mihael