swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Swagger editor won't put false boolean values in the URL for "try this operation"

Open Syzygy24 opened this issue 11 years ago • 22 comments

The segment in question is

parameters:
          name: debug
          in: query
          description: |
            Parameter must be included as part of the URI. If set to true, ERROR
            message will return full entity response message.
            ** keep off if performance is a consideration **
          required: false
          type: boolean
          default: false
          allowEmptyValue: false

Our api won't allow requests with an empty debug value. I would just like to be able to pass "false" in, but nothing I tried will allow it. Changing it to true makes it work just fine, but there are performance considerations with that feature. Changing the value to false in the dropdown menu just makes it an empty string rather than false and the response returns an error because we passed in an empty value for debug.

GET http://{url}/v1/stores?debug= HTTP/1.1

Adding "allowEmptyValue: false", changing required to true, and adding "default: false" haven't helped. Is there a way around this?

Syzygy24 avatar Jul 09 '15 19:07 Syzygy24

It doesn't put false boolean values into bodies neither.

hantuzun avatar Aug 23 '15 15:08 hantuzun

Hi, is this problem fixed? When will it be fixed? I am experiencing the same problem. thanks

ghost avatar Oct 07 '15 12:10 ghost

I am also seeing this problem using editor.swagger.io today 2016-01-01

mkrufky avatar Jan 01 '16 19:01 mkrufky

I am hitting this as well.

Is this desired behavior by Swagger for some reason?

jwthomp avatar Jan 22 '16 20:01 jwthomp

No, this is a bug. We're working on it, but it's caused deep in one of the dependencies. We'll close this out when it's addressed (I know, it's annoying).

fehguy avatar Jan 22 '16 20:01 fehguy

@fehguy That's great, thank you for the update and answer.

jwthomp avatar Jan 22 '16 20:01 jwthomp

Are you still working on this bug? It makes my API not work properly. Is there a workaround?

puncha avatar Mar 18 '16 06:03 puncha

I guess this issue has been fixed now. Would anyone take a moment and test it please?

saharj avatar Apr 21 '16 06:04 saharj

Just tested it after fresh fetch, rebase, and install, and the issue is still there. Can get $count=true into the URL but not $count=false. Which doesn't bother me because omitting $count is equivalent to $count=false in my APIs :-)

ralfhandl avatar Apr 21 '16 14:04 ralfhandl

I also did the test, the bug is still there. Different from ralfhandl, it bothers me a lot. It is not possible for me to re-design my API to walk around this bug.

puncha avatar Apr 22 '16 02:04 puncha

This is a dependency issue: https://github.com/jdorn/json-editor/issues/406

saharj avatar Apr 22 '16 03:04 saharj

can confirm I am still hitting this issue.

jpetitte avatar Mar 01 '17 02:03 jpetitte

Same here. I wish that would be possible. It doesn't show the properties in the model example list.

jenswachtel avatar Apr 28 '17 11:04 jenswachtel

@jenswachtel do you experience that with the 3.x editor?

webron avatar Apr 28 '17 15:04 webron

Closing as should be fixed. File a new ticket if not.

webron avatar Jun 08 '17 23:06 webron

@webron The issue still persists for me. I even checked out the http://editor2.swagger.io/#!/ to check if it's a user error on my end, but it seems that by making the following change under /products => get => parameters:

          in: query
          description: Latitude component of location.
          required: true
          type: boolean

When selecting false, it does not appear in the query (I am trying to put the boolean in the body). Unfortunately, for me it's essential that I use a boolean...if I change the type to string, it works, but only if the user inputs either true or false (and that is prone to error - "tue", "fasle", etc.).

Perhaps this has already been fixed or there is a workaround? :) Thanks!

zoharsanchez avatar Aug 23 '17 05:08 zoharsanchez

@zoharsanchez tested it with the current editor, and it sends the query parameter just fine...

webron avatar Aug 23 '17 20:08 webron

@webron Hmmm, that's strange, I'm still getting the error...I made the same change as above and when I click on false, I get this for the query: GET https://api.uber.com/v1/products?latitude=&longitude= versus if I click true: GET https://api.uber.com/v1/products?latitude=&longitude=true

Am I doing something wrong? 🤔

Note: I did try it out on Petstore and it worked there.

zoharsanchez avatar Aug 24 '17 07:08 zoharsanchez

Which version of the editor do you use?

webron avatar Aug 24 '17 13:08 webron

@webron 2.0, same as that in http://editor2.swagger.io/#!/

zoharsanchez avatar Aug 24 '17 18:08 zoharsanchez