3

Wadl can be configured in Dropwizard 0.7.1 like this:

environment
        .jersey()
        .getResourceConfig()
        .getProperties()
        .put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.FALSE);//Create WADL

How can I set it in Dropwizard 0.8.0

heaphach
  • 1,492
  • 1
  • 20
  • 44
  • I think WADL is enabled by default in Jersey 2. See [Configuration](https://jersey.java.net/documentation/latest/wadl.html#d0e13101). In general, to set a property, you can just use [`jersey().property(...)`](https://github.com/dropwizard/dropwizard/blob/master/dropwizard-jersey/src/main/java/io/dropwizard/jersey/setup/JerseyEnvironment.java#L87) – Paul Samsotha Mar 09 '15 at 12:59
  • Then is this correct? environment .jersey() .getResourceConfig() .getProperties() .put("jersey.config.server.wadl.disableWadl", Boolean.TRUE); – heaphach Mar 09 '15 at 14:26
  • You are disabling the feature with that. I thought you want it enabled. – Paul Samsotha Mar 09 '15 at 15:06
  • I want to configure it via my config file – heaphach Mar 09 '15 at 15:20
  • Well, the `Configuration` is passed into the `run` method, along with the `Environment`. I don't see why you can't put the value into the configuration file. If you're looking for something built in to dropwizard, I don't see anything, [but you can check again](https://dropwizard.github.io/dropwizard/manual/configuration.html#all). If it's not there, you can always make a request – Paul Samsotha Mar 09 '15 at 15:27

2 Answers2

8

The location of the property key has changed and the map is unmodifiable - so you'll need to use the addProperties method instead:

import org.glassfish.jersey.server.ServerProperties;
...
Map<String, Object> properties = new HashMap<>();
properties.put(ServerProperties.WADL_FEATURE_DISABLE, false);
environment.jersey().getResourceConfig().addProperties(properties);

And as of 0.8.0 Dropwizard is disabling WADL generation so you'll need to turn it on explicitly.

condit
  • 10,852
  • 2
  • 41
  • 60
1
import org.glassfish.jersey.server.ServerProperties;
...
environment.jersey().disable(ServerProperties.WADL_FEATURE_DISABLE);
Valeriy
  • 79
  • 1
  • 2
  • How and why, exactly, does this code answer the question? Could you please add some context? – pppery Apr 17 '19 at 12:54