2015-05-14 16 views
10

Tôi nhận được lỗi Data does not match any schemas from 'oneOf' với spec sau:Lỗi xác thực: Dữ liệu không phù hợp với bất kỳ lược đồ từ 'oneof'

{ 
    "info": { 
    "version": "1.0.0", 
    "title": "REST API" 
    }, 
    "paths": { 
    "/doit": { 
     "post": { 
     "responses": { 
      "200": { 
      "description": "Successful response" 
      } 
     }, 
     "parameters": [ 
      { 
      "type": "object", 
      "schema": { 
       "$ref": "#/definitions/ResponseDefinition" 
      }, 
      "required": "true", 
      "name": "docs", 
      "in": "body" 
      } 
     ] 
     } 
    } 
    }, 
    "swagger": "2.0", 
    "definitions": { 
    "ResponseDefinition": { 
     "type": "object", 
     "properties": { 
     "text": { 
      "type": "string", 
      "description": "" 
     } 
     } 
    } 
    } 
} 

errorfrom đầy đủ nay, vênh vang-công cụ validator:

#/paths/~1doit/post/parameters/0: Data does not match any schemas from 'oneOf' 
#/paths/~1doit/post/parameters/0: Data does not match any schemas from 'oneOf' 
    #/required: Expected type boolean but found type string 
    #/: Missing required property: type 
#/paths/~1doit/post/parameters/0: Additional properties not allowed: in,name,required,schema 

Tôi không hiểu lỗi hoặc cách giải quyết.

Trả lời

13

Bạn không được bao gồm type trong thông số body. Đó là lý do tại sao có schema. Hãy thử điều này:

{ 
    "info": { 
    "version": "1.0.0", 
    "title": "REST API" 
    }, 
    "paths": { 
    "/doit": { 
     "post": { 
     "responses": { 
      "200": { 
      "description": "Successful response" 
      } 
     }, 
     "parameters": [ 
      { 
      "schema": { 
       "$ref": "#/definitions/ResponseDefinition" 
      }, 
      "required": "true", 
      "name": "docs", 
      "in": "body" 
      } 
     ] 
     } 
    } 
    }, 
    "swagger": "2.0", 
    "definitions": { 
    "ResponseDefinition": { 
     "type": "object", 
     "properties": { 
     "text": { 
      "type": "string", 
      "description": "" 
     } 
     } 
    } 
    } 
} 
+0

Bạn có phiền khi bạn nhận thông tin này từ đâu không? –

+0

Bạn đang đề cập đến factoid nào? – Ron

+0

Dòng đầu tiên của câu trả lời của bạn. –

Các vấn đề liên quan