2017-04-24 41 views
8

我想用Swagger编辑器编写一个简单的Swagger/Open API定义。Swagger参数错误“不完全是一个来自<#/ definitions/parameter>”?

swagger: "2.0" 

info: 
    version: 1.0.0 
    title: Test API 
    description: Test API 

schemes: 
    - https 
host: hipaa.ai 
basePath: /v1 

paths: 
    /comments: 
    post: 
     summary: Your comments 
     description: Comments 
     parameters: 
     - name: text 
     in: body 
     description: An array of text strings 
     type: array 
     minItems: 1 
     maxItems: 1000 
     items: 
      type: text 

,我发现了以下错误:

Schema error at paths./comments.post.parameters[0] 
is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference> 

我已检查扬鞭架构参考,并PetStore的例子,但我不知道为什么我得到这个。有任何想法吗?

回答

9

车身参数使用schema关键字指定的类型,所以你需要移动typeitemsminItemsmaxItemsschema下。

另外,type: text不是valid type。改为使用type: string

 parameters: 
     - name: text 
     in: body 
     description: An array of text strings 
     schema: 
      type: array 
      minItems: 1 
      maxItems: 1000 
      items: 
      type: string 
相关问题