1

If we open the swagger editor website https://editor.swagger.io/ it has one default swagger example. The first several lines are

swagger: "2.0"
info:
  description: "This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters."
  version: "1.0.0"

Generally we know there are two types of swagger file. YAML and json. The default of course is not JSON. And the default is very similar to YAML but it is not. Because in the menu and we can choose “convert to YAML” and it will convert to

swagger: '2.0'
info:
  description: >-
    This is a sample server Petstore server.  You can find out more about    
    Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net,
    #swagger](http://swagger.io/irc/).      For this sample, you can use the api
    key `special-key` to test the authorization     filters.
  version: 1.0.0

we can see some " change to ' and some " are removed.

I am wondering what is name of this default type and where is definition of that format? What is difference of it with YAML? In this website https://swagger.io/docs/specification/2-0/basic-structure/ it has YAML definition and but I can not find any defination of the default format.

Thanks

Michael
  • 11
  • 2

1 Answers1

1

These YAML examples are equivalent, they just use different ways to format strings. YAML strings can use both single and double quotes, and in some cases (like version: 1.0.0) quotes can be omitted. There are also several ways to split long strings (such as description in your example) into multiple lines and format multi-line strings.

Helen
  • 87,344
  • 17
  • 243
  • 314
  • Thanks Helen. Another releated question. If I convert it to openapi 3 by choose "Convert to openapi 3"(which says convertion is done by https://converter.swagger.io/api/convert), the response such as 200 then change to no single quote, which is failed to validate in one of my local software. Then I choose "convert to YAML" again and it convert to openapi 3 YAML version and it is successfully to validate. Accroding to https://swagger.io/specification/, The response must be enclosed. Is something wrong with https://converter.swagger.io/api/convert? – Michael Aug 14 '21 at 00:34
  • Response codes should be quoted. Feel free to open an issue in the converter repo: https://github.com/swagger-api/swagger-converter/issues – Helen Aug 16 '21 at 07:11