loic911 / Rest-api-doc

MIT License
21 stars 32 forks source link

support rest params as methods arguments #15

Open anthony-foulfoin opened 10 years ago

anthony-foulfoin commented 10 years ago

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 :)

loic911 commented 10 years ago

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.