How to pass empty value to a query param in swagger? -


i trying access url similar http://example.com/service1?q1=a&q2=b. q1 not have values associated required access service (http://example.com/service1?q1=&q2=b). how achieve through swagger ui json. i've tried using allowemptyvalue option doesn't seem work.

please find below sample json tried using allowemptyvalue option,

{     "path": "/service1.do",     "operations": [{         "method": "get",         "type": "void",         "parameters": [{                 "name": "q1",                 "in" : "query",                 "required": false,                 "type": "string",                 "paramtype": "query",                 "allowemptyvalue": true             },{                 "name": "q2",                 "in" : "query",                 "required": true,                 "type": "string",                 "paramtype": "query",             }           ],         "responsemessages": [{             "code": 200,             "responsemodel": "/successresponsemodel"         } } 

when empty value passed q1, swagger frames url http://example.com/service1?q2=b. there anyway include q1 empty values included in url (http://example.com/service1?q1=&q2=b) ?

any appreciated.

it looks problem known issue of swagger-ui hasn't fixed yet. see.

as workaround may 1 of followings.

option 1: specify default value.

this option have nothing swagger-ui. in ws-implementation, have add default value(in case "") use when 'q1' not added. rest framework has option.

as ws-implementation perspectives, should there in ws, unless have service triggered when 'q1' not added. (which might not design in cases) , can use forever solution, not temporary.

option 2: using enums (not consistent solution)

as explained in this. can specify query parameter 'q1' follows swagger definition.

{                  "in": "query",                  "name": "q1",                  "type": "boolean",                  "required": false,                  "enum" : [true],                  "allowemptyvalue" : true } 

(1) "required" must false.

(2) "allowemptyvalue" must true.

(3) "enum" must have 1 non-empty value.

(4) "type" must "boolean". (or "string" special enum, "include")


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -