首页 > 解决方案 > openapi oneOf 的 WSDL 等效项是什么?

问题描述

目前我需要找出 openapi ( oneOf - openapi ) 中的 oneOf 在 WSDL 中的样子。oneOf 的定义是:

oneOf – 仅针对其中一个子模式验证值

如果 oneOf 文档说(JSON)对象应该仅对指定的模式之一有效。如果对象对多个模式有效,则它将无效/不正确。

不幸的是,我不是 WSDL 专家,所以我不确定您如何在 WSDL 中表示类似 oneOf 的内容。我以为我可以做这样的事情:

Openapi-示例

schemas:
  fruit:
     title: fruit
     properties:
        color:
           type: string
     oneOf:
        - $ref: '#/components/schemas/apple'   <- schema with property 'kind'
        - $ref: '#/components/schemas/banana'  <- schema with property 'count'

WSDL 等效

  <xs:complexType name="Fruit">
    <xs:sequence>
      <xs:element minOccurs="0" name="color" type="xs:string" />
      <xs:element minOccurs="0" name="apple" type="schemas:apple" />
      <xs:element minOccurs="0" name="banana" type="schemas:banana" />
    </xs:sequence>
  </xs:complexType>

  Or maybe this one

  <xs:complexType name="Fruit">
    <xs:sequence>
      <xs:element minOccurs="0" name="color" type="xs:string" />
      <xs:element minOccurs="0" name="kind" type="xs:string" />
      <xs:element minOccurs="0" name="count" type="xs:double" />
    </xs:sequence>
  </xs:complexType>

也许这是一种变通方法,但即使两种 WSDL 构造都没有真正限制其中一种模式;如前所述,该对象应该仅对指定的模式之一有效。

有谁知道如何在 WSDL 中表示 oneOf?

标签: soapwsdlopenapi

解决方案


推荐阅读