loic911 / Rest-api-doc

MIT License
21 stars 32 forks source link

REST API ignores "required" property in defaultParamsQueryAll (List) #63

Closed lionkng123 closed 8 years ago

lionkng123 commented 8 years ago

It seems, this plugin does neglect "required" property from defaultParamsQueryAll list in Config.groovy

In Config.groovy:

grails.plugins.restapidoc.defaultParamsQueryAll =  [
    [name:"isValid",description:"Some description of 'isValid' query param", required: "true", type: "String"]
]

As per JSONDocUtilsLight, we are hard-coding required as false:

DEFAULT_PARAMS_QUERY_ALL.each {
    queryParameters.add(new RestApiParamDoc(it.name, it.description, it.type, "false", new String[0], Enum, ""))
}

Is it expected behavior?

Shall we read this property from Config.groovy where default would be false?

Something like this:

DEFAULT_PARAMS_QUERY_ALL.each {
     queryParameters.add(new RestApiParamDoc(it.name, it.description, it.type, it.required ?: "false", new String[0], Enum, ""))
}

Thank you

loic911 commented 8 years ago

Yes, I commit the fix. Should be available in the next release.