Yaml 使用「;其中一个;在OAS 3.0中,多个标准为;“必需”;性质

Yaml 使用「;其中一个;在OAS 3.0中,多个标准为;“必需”;性质,yaml,swagger,swagger-codegen,Yaml,Swagger,Swagger Codegen,需要利用OAS 3.0中的“oneOf”来支持多个标准 我的模型对象看起来像这样- DiskDataSourceSpec: title: "Source corresponding to the Volume Disk" description: "Spec comprising the source corresponding to the Volume Disk." type: "object" oneOf: - require

需要利用OAS 3.0中的“oneOf”来支持多个标准

我的模型对象看起来像这样-

DiskDataSourceSpec:
      title: "Source corresponding to the Volume Disk"
      description: "Spec comprising the source corresponding to the Volume Disk."
      type: "object"
      oneOf:
        - required:
            - containerUUID
        - required:
            - volumeDiskUUID
      properties:
        containerUUID:
          type: "string"
          description: "Storage container UUID on which the disk must be created."
        volumeDiskUUID:
          type: "string"
          description: "An existing disk whose contents must be cloned."
然而,OAS 3.0似乎不支持这种编写“oneOf”的方式

我可以在其中一个下使用$ref来支持不同的模型,但这里我需要将其应用于属性


需要帮助找出执行此操作的正确方法吗?

您的定义在OAS3中完全有效,您所说的“不受支持”是什么意思?您对某些工具(如codegen)有问题吗?@Helen是的,codegen似乎无法正确生成它。它只生成一个没有任何属性的类。只存在一个默认构造函数。如果我完全删除
部分中的
部分,那么这两个属性都是类的一部分。