package com.hypnoticocelot.jaxrs.doclet.sample;

import com.google.common.base.Optional;
import com.yammer.dropwizard.Service;
import com.hypnoticocelot.jaxrs.doclet.sample.resources.AuthResource;
import com.hypnoticocelot.jaxrs.doclet.sample.resources.GreetingsResource;
import com.hypnoticocelot.jaxrs.doclet.sample.resources.HttpServletRequestResource;
import com.hypnoticocelot.jaxrs.doclet.sample.resources.ResponseResource;
import com.yammer.dropwizard.assets.AssetsBundle;
import com.yammer.dropwizard.auth.AuthenticationException;
import com.yammer.dropwizard.auth.Authenticator;
import com.yammer.dropwizard.auth.basic.BasicAuthProvider;
import com.yammer.dropwizard.auth.basic.BasicCredentials;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Configuration;
import com.yammer.dropwizard.config.Environment;

public class SampleService extends Service<Configuration> {
    public static void main(String[] args) throws Exception {
        new SampleService().run(args);
    }

    @Override
    public void initialize(Bootstrap<Configuration> bootstrap) {
        bootstrap.addBundle(new AssetsBundle("/apidocs", "/apidocs", "index.html"));
    }

    @Override
    public void run(Configuration configuration, Environment environment) throws Exception {
        environment.addProvider(new BasicAuthProvider<>(new Authenticator<BasicCredentials, String>() {
            @Override
            public Optional<String> authenticate(BasicCredentials basicCredentials) throws AuthenticationException {
                return Optional.of("USERNAME");
            }
        }, "AuthResource Realm"));

        environment.addResource(new GreetingsResource());
        environment.addResource(new HttpServletRequestResource());
        environment.addResource(new AuthResource());
        environment.addResource(new ResponseResource());
    }
}

@@ -86,46 +86,8 @@
 al;%0A
-import com.yammer.dropwizard.Service;%0A
 impo
@@ -138,28 +138,17 @@
 sources.
-AuthResource
+*
 ;%0Aimport
@@ -156,226 +156,31 @@
 com.
-hypnoticocelot.jaxrs.doclet.sample.resources.GreetingsResource;%0Aimport com.hypnoticocelot.jaxrs.doclet.sample.resources.HttpServletRequestResource;%0Aimport com.hypnoticocelot.jaxrs.doclet.sample.resources.ResponseResour
+yammer.dropwizard.Servi
 ce;%0A
@@ -1389,16 +1389,69 @@
 lm%22));%0A%0A
+        environment.addResource(new AuthResource());%0A
         
@@ -1595,36 +1595,41 @@
 addResource(new 
-Auth
+Recursive
 Resource());%0A   

Reorder resource registration and add the RecursiveResource to the registered list.