在bluemix上使用api connect验证错误:数据与'oneOf'中的任何模式都不匹配

时间:2017-02-09 10:07:03

标签: api yaml ibm-cloud apiconnect

我收到错误Data does not match any schemas from 'oneOf',其中包含以下规范:

product: 1.0.0
info:
  name: account-information
  title: Account Information
  version: 1.0.10
  termsOfService: >-
    These API are a PSD2 implementation example. The service might be
    discontinued at any time
visibility:
  view:
    type: public
  subscribe:
    type: authenticated
plans:
  premium:
    title: Premium
    apis: {}
    rate-limit:
      value: 1000/1minute
      hard-limit: true
    approval: true
  default:
    title: Default Plan
    description: Default Plan
    approval: false
    rate-limit:
      value: 100/hour
      hard-limit: true
apis:
  account:
    $ref: account.yaml
  subscription:
    $ref: subscription.yaml

完整的错误消息:

  

消息:“数据与”oneOf“中的任何模式都不匹配,”Chemindedonnées:“”,Chemindeschéma:“/ oneOf”

     

消息:“不允许使用其他属性”,Chemindedonnées:“/ name”,Chemindeschéma:“/ oneOf / 0 / additionalProperties”

我不明白错误来自何处以及如何解决。

1 个答案:

答案 0 :(得分:1)

对于API Connect,我认为您希望使用 x-ibm-name 而不是名称。我能够使用上面的示例验证以下规范:

info:
  title: Account Information
  x-ibm-name: account-information
  version: 1.0.10
visibility:
  view:
    type: public
  subscribe:
    type: authenticated
plans:
  premium:
    title: Premium
    apis: {}
    rate-limit:
      value: 1000/1minute
      hard-limit: true
    approval: true
  default:
    title: Default Plan
    description: Default Plan
    approval: false
    rate-limit:
      value: 100/hour
      hard-limit: true
apis:
  account:
    $ref: account.yaml
  subscription:
    $ref: subscription.yaml

注意:我还删除了产品字段。

您还可以使用“设计”选项卡让API Connect以正确的格式自动创建源:

enter image description here