loic911 / Rest-api-doc

MIT License
21 stars 32 forks source link

Default PATH parameters #37

Open raffian opened 9 years ago

raffian commented 9 years ago

Is it possible to define default PATH parameters at the controller level, instead of repeating them for each action? For instance, many of our actions use Date as a PATH parameter...

@RestApiMethod(description="Get customer orders")
   @RestApiParams(params=[
      @RestApiParam( name="customer_id",
                        type="String",
                        paramType = RestApiParamType.PATH)
      @RestApiParam( name="date",
                        type="Date",
                        paramType = RestApiParamType.PATH,
                        description = "YYYY-MM-DD")])
def customerOrders(){...}

@RestApiMethod(description="Get customer wish lists")
   @RestApiParams(params=[
      @RestApiParam( name="customer_id",
                        type="String",
                        paramType = RestApiParamType.PATH)
      @RestApiParam( name="date",
                        type="Date",
                        paramType = RestApiParamType.PATH,
                        description = "YYYY-MM-DD")])
def customerWishLists(){ ... }

It would be nice if we can define the Date param on the controller, or as config object:

@RestApi(name = "Customer services")
   @DefailtRestApiParams(params=[
      @RestApiParam( name="date",
                        type="Date",
                        paramType = RestApiParamType.PATH,
                        description = "YYYY-MM-DD")])
class CustomerController { ... } 
//Config.groovy
grails {
   plugins {
      restapidoc {
         customer {  //specific to CustomerController
            defaultParamsPathAll =
               [[name:"as_of_date",
                 type:"Date",
                 description:"As of date: YYYY-MM-DD."]]
             }
         }
    }
}