APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

bundle removes quotes #89

Open dwt opened 1 year ago

dwt commented 1 year ago

Hi there,

I've got the problem that I have an openapi spec that looks like this (small excerpt):

something:
  example: "3914364093"
  type: string
something_else:
  example: "015711521886"
  type: string

These two look quite similar, but because of the leading 0, when combing the file that contains this yaml with the main openapi.yaml it gets converted to this:

something:
  example: '3914364093'
  type: string
something_else:
  example: 015711521886
  type: string

So a) the quotes get converted (I see nothing bad there) but b) for something_else the quotes around the example get removed.

The last one is quite bad, as that means that any yaml interpreter is free to interpret the example as a number instead of a string (even though that type is clearly stated in the next line).

Running this to redocly does exactly that, and the example gets rendered as an int (thus loosing the leading zero).

Workarounds: It seems that using the json output format instead doesn't strip the quotes, so that is something I'm going to try for the time being, but it's definitely something I would like to not do in the long run as yaml is much easier to read and also much closer to what we actually write.

What would I like?