Apiblueprint 如何为MSON中的数组指定多个可能的类型(类型联合)?
我有点难以准确地描述我需要什么,但我花了一些时间浏览MSON规范,没有找到任何东西 这个例子有点做作,但希望意图是明确的Apiblueprint 如何为MSON中的数组指定多个可能的类型(类型联合)?,apiblueprint,mson,Apiblueprint,Mson,我有点难以准确地描述我需要什么,但我花了一些时间浏览MSON规范,没有找到任何东西 这个例子有点做作,但希望意图是明确的 # Animal (object) This is a base class for all animals. It provides some common structure. ## Properties ... some properties # Bird (Animal) ## Properties ... some properties # Fish
# Animal (object)
This is a base class for all animals. It provides some common structure.
## Properties
... some properties
# Bird (Animal)
## Properties
... some properties
# Fish (Animal)
## Properties
... some properties
# Farm (Object)
## Properties
+ animals (array[Animal], fixed-type)
我想表达的是,农场可以容纳各种动物,但不能容纳基本类。是否有某种方式可以在MSON/JSON模式中表达这一点,以便进行验证?实际上,我想要一个选择,或者说是一种鸟和鱼的结合。我不介意明确地写出这些类
非常感谢。既然您可以显式写出类,我认为可以通过写出数组接受的类型(这些类型恰好都是Animal的子类)来完成
+ animals (array[Fish, Bird], fixed-type)