Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Spring Controller methods from Generic-based superclass? #138

Open
manosbatsis opened this issue Aug 20, 2015 · 7 comments
Open

Comments

@manosbatsis
Copy link

My project has many controllers like this one:

@Controller
@RequestMapping(value = "/api/rest/texts", produces = { "application/json", "application/xml" })
public class TextController extends AbstractServiceBasedRestController<Text, String, TextService> {
    @Override
    @Inject
    @Qualifier("textService") // somehow required for CDI to work on 64bit JDK?
    public void setService(TextService service) {
        this.service = service;
    }
}

They all extend a generic controller like this one:

RequestMapping(produces = { "application/json", "application/xml" })
public abstract class AbstractServiceBasedRestController<T extends Persistable<ID>, ID extends Serializable, S extends GenericEntityService<T, ID>>
        extends ServiceBasedRestController<T, ID, S> {
    @Override
    @ApiMethod
    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public Page<T> findPaginated(
            @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
            @RequestParam(value = "size", required = false, defaultValue = "10") Integer size,
            @RequestParam(value = "properties", required = false, defaultValue = "id") String sort,
            @RequestParam(value = "direction", required = false, defaultValue = "ASC") String direction) {
        // do something
    }
}

How can I make JSONDoc document the generic superclass methods for each concrete Controller class?

@manosbatsis
Copy link
Author

I suppose my question is, am I missing something or should i consider an attempt to a scanner patch?

@fabiomaffioletti
Copy link
Owner

No, you are not missing anything. A patch to the scanner is the way to go.

@manosbatsis
Copy link
Author

I can fix this for Spring but refactoring JSONDocTypeBuilder.build looks like a better way. To clarify, passing the controller (or whatnot) implementation class there would allow better resolution of generics in a single place.

@manosbatsis
Copy link
Author

Bah, ignore previous comment, JSONDocTypeBuilder wont know what to do with it, it just wants properly resolved stuff passed to it's build method. I'll just fix the spring builders.

@maximelebastard
Copy link

Hi @fabiomaffioletti ! Can you tell in which version the patch will be available ?

@manosbatsis
Copy link
Author

Gave that up back then, did not have the time to refactor that much. If i recall correctly other class methods had to be changed for the generic types and collections to resolve properly.

@maximelebastard
Copy link

I'll take a look, thanks !

2015-11-25 11:20 GMT+01:00 manosbatsis notifications@github.com:

Gave that up back then, did not have the time to refactor that much. If i
recall correctly other class methods had to be changed for the generic
types and collections to resolve properly.


Reply to this email directly or view it on GitHub
#138 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants