首页 文章

如何在Swagger编辑器中使用JSON主体指定POST

提问于
浏览
0

我有一个POST方法REST API,请求体为json,它有

{
    "name": "5-Star",
    "vendor": "Cadbury",
    "description": "More almonds with chocolate",
    "price": 5,
    "primaryImage": "http://cdn.shopify.com/s/files/1/0219/2362/products/Front_a8743e5a-c6a3-4042-9cb2-834332af77d5_large.jpg?v=1377892407",
    "variants": 
        [
          { "name" : "size", 
            "type" : null, 
            "defaultValue" : "8",
            "values" :[ "8","8.5"]
          },
          { "name" : "color", 
            "type" : "COLOR", 
            "values" :[ "Milky White","Chocolate"]
          }
       ],
    "tags": 
       [ "Chocolate", "Cadbury"  ]
    }

我需要知道如何在swagger 2.0编辑器中的上述json中为 variants 设置参数,也从swagger引用文档和petstore示例,但我无法找到任何线索 .

1 回答

  • 2

    也许这会让你开始:

    properties:
     ... // other stuff
      variants:
        type: array
        description: variants description
        items:
          properties:
            name:
              type: string
              description: the name
     ... // the rest
    

相关问题