[英]Swagger error when trying to import JSON
我已經成功使用查詢參數定義了API,但想通過JSON對象傳遞所有狀態。
我定義了以下YAML文件:
paths:
/contact-us:
post:
summary: Contact Us
description: |
Originates a new conversation thread
consumes:
- application/json
parameters:
- in: body
required: true
schema:
$ref: '#/definitions/RequestConversation'
tags:
- Email
responses:
200:
description: New conversation has been originated
schema:
$ref: '#/definitions/Conversation'
這導致parameters
行出現錯誤,指出:
數據與“ oneOf”中的任何模式都不匹配
但是我在同一個YAML文件中確實具有以下定義:
definitions:
RequestConversation:
type: object
properties:
company_id:
type: string
# required: true
user_email:
type: string
# required: true
type:
type: string
# required: true
default: 'contact-us'
sub_type:
type: string
campaign:
type: string
另請注意,“必需”的定義已被注釋掉,這是因為它們給了我一個不同的錯誤:
預期的類型數組,但發現類型為布爾值
有人可以幫忙嗎?
好了,解決了我自己的問題(至少是第一部分)。 希望這將使其他人受益:
實際上,第一個問題是我沒有指定所需的“名稱”屬性。
它仍然是打開的(又可以使用,但是不能使用“必需”屬性)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.