hoegertn / restdoc-java-server

Java Server implementation of RestDoc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@RestDoc should be allowed on classes (which model subresources)

koppor opened this issue · comments

I'm using classes as subresources, which are instantiated by the parent resource. I tried to annotate that resource class with @RestDoc(resourceDescription = "..."), but the location class is not allowed for @RestDoc.

RestDoc resources have to be callable endpoints so only methods can be annotated. Subresources are only parts of the endpoint.

Maybe, I don't get, what a callable endpoint is :). I have the URL http://.../winery/winerypropertiesdefinition, where I can POST to. Is that an endpoint?

public class WinerysPropertiesDefinitionResource {

    @POST
    @RestDoc(methodDescription = "switches the mode to winery properties")
    public Response onPost() {
        // ...
    }

}

That resource is created by the parent resource.

    @Path("winery/")
    public WinerysPropertiesDefinitionResource getWinerysPropertiesDefinitionResource() {
        return new WinerysPropertiesDefinitionResource();
    }

I see that I could make the annotation there. I currently think it is better positioned at the place where the actual implementation (or interface definition ;)) resides.

I see the problem, I think I will split resourceDescription and methodDescription into separate annotations. That may solve the problem.