i checking out following tutorial: http://blogs.msdn.com/b/martinkearn/archive/2015/03/10/using-odata-query-syntax-with-web-api.aspx
and curious if there support in swagger ui somehow show query parameters.
essentially wanted calls tagged [enablequeryattribute] attribute have swagger ui inputting query parameters , don't want add these parameters method call still want them in url , pulled out owin context.
any suggestions?
the answer easier thinking. ended doing creating ioperationfilter , looked operations return type , added parameters it.
class queryparameterfilter : ioperationfilter { void ioperationfilter.apply(operation operation, schemaregistry schemaregistry, apidescription apidescription) { if (apidescription.responsedescription.responsetype != null && apidescription.responsedescription.responsetype.name.contains("pagedresult")) { dictionary<string, string> parameters = new dictionary<string, string>() { { "$top", "the max number of records"}, { "$skip", "the number of records skip"}, { "$filter", "a function must evaluate true record returned"}, { "$select", "specifies subset of properties return"}, { "$orderby", "determines values used order collection of records"} }; operation.parameters = new list<parameter>(); foreach (var pair in parameters) { operation.parameters.add(new parameter { name = pair.key, required = false, type = "string", @in = "query", description = pair.value }); } } } and can retrieved through owin context.
var params = owincontext.request.query.todictionary(p => p.key, p => p.value.firstordefault());
Comments
Post a Comment