Rest-api-doc icon indicating copy to clipboard operation
Rest-api-doc copied to clipboard

support rest params as methods arguments

Open anthony-foulfoin opened this issue 10 years ago • 1 comments

Hi,

With grails there are two ways to access url parameters :

// First one, as a controller method argument 
def index(String query) {
    // ...
}
// Second one, with the params object
def index() {
 String query = params.query
 // ...
}

If we use the first solution, and use restapidoc to doc the params, we must do the following :

@RestApiParams(params=[
      @RestApiParam(name="query", type="String",  paramType = RestApiParamType.QUERY, description = "my query")
    ])
def index(String query) {
    // ...
}

When getting params like this, restapidoc can directly have the type and the name. It would be great if we could do something like that :

def index( @RestApiParam(description="my query")
           String query
          ) {
    // ...
}

That's less boilerplate :)

anthony-foulfoin avatar Aug 07 '14 15:08 anthony-foulfoin

I've done a small fix for that: The type will be automatically retrieve if method has parameters. @RestApiParam(name="query", type="String", paramType = RestApiParamType.QUERY,description = "my query") could be: @RestApiParam(name="query", paramType = RestApiParamType.QUERY,description = "my query")

Not perfect but a good start ;-) It will be available in 0.3.

loic911 avatar Aug 13 '14 19:08 loic911