2017-03-08 205 views
0

我想为休息api定义一个简单的swagger定义。我的所有参数部分都出现错误。Swagger错误 - 描述:“不是一个有效的参数定义”

我在swagger编辑器中遇到了swagger定义错误,我没有得到任何线索,我错了。请指教。

扬鞭定义:

paths: 
'/customer/{customerId}/accountlist': 
get: 
    responses: 
    '200': 
     description: '' 
    parameters: 
    - name: customerId 
     in: path 
     allowMultiple: false 
     required: true 
     type: string 
    x-auth-type: None 
    x-throttling-tier: Unlimited 
    produces: 
    - application/json 
    x-scope: InternalUse 
    swagger: '2.0' 
    info: 
    title: Sample 
    description: API for Sample 

扬鞭错误:

Swagger Error 
Not a valid parameter definition 
Jump to line 7 
Details 
Object 
code: "ONE_OF_MISSING" 
params: Array [0] 
message: "Not a valid parameter definition" 
path: Array [5] 
0: "paths" 
1: "/customer/{customerId}/accountlist" 
2: "get" 
3: "parameters" 
4: "0" 
schemaId: "http://swagger.io/v2/schema.json#" 
inner: Array [2] 
0: Object 
code: "ONE_OF_MISSING" 
params: Array [0] 
message: "Data does not match any schemas from 'oneOf'" 
path: Array [5] 
0: "paths" 
1: "/customer/{customerId}/accountlist" 
2: "get" 
3: "parameters" 
4: "0" 
inner: Array [2] 
0: Object 
code: "OBJECT_MISSING_REQUIRED_PROPERTY" 
params: Array [1] 
0: "schema" 
message: "Missing required property: schema" 
path: Array [0] 
1: Object 
code: "ONE_OF_MISSING" 
params: Array [0] 
message: "Data does not match any schemas from 'oneOf'" 
path: Array [0] 
inner: Array [4] 
1: Object 
code: "OBJECT_MISSING_REQUIRED_PROPERTY" 
params: Array [1] 
0: "$ref" 
message: "Missing required property: $ref" 
path: Array [5] 
0: "paths" 
1: "/customer/{customerId}/accountlist" 
2: "get" 
3: "parameters" 
4: "0" 
level: 900 
type: "Swagger Error" 
description: "Not a valid parameter definition" 
lineNumber: 7 
+0

请在您的问题中最好以YAML格式包含Swagger/OpenAPI定义。 –

+0

添加示例swagger定义作为问题的一部分。 – Pravin

回答

2

我改写了你的OpenAPI的规范。这个版本是有效的:

swagger: '2.0' 

info: 
    title: Sample 
    version: 1.0.0 
    description: API for Sample 

paths: 
    '/customer/{customerId}/accountlist': 
    get: 
     responses: 
     '200': 
      description: '' 
     parameters: 
     - name: customerId 
      in: path 
      required: true 
      type: string 
     x-auth-type: None 
     x-throttling-tier: Unlimited 
     produces: 
     - application/json 
     x-scope: InternalUse 

你的原始版本的一些评论:

  • 缩进不好。例如get:行需要从前一行缩进。但也许这只是一个复制&粘贴问题。

  • info对象需要version属性。

  • customerId参数包括allowMultiple属性。我看到一个错误,直到我删除它。

+0

谢谢戴夫。有效。 allowMultiple是扰流板。 – Pravin

相关问题