On 03/31/2015 12:15 PM, Eric Blake wrote: >>> Cool. Or more concretely, >>> >>> { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } } >>> >>> is identical on the wire to: >>> >>> { 'enum': 'MyEnum', 'data': ['one', 'two'] } >>> { 'type': 'Base', 'data': { 'type': 'MyEnum' } } >>> { 'type': 'Branch1', 'data': { 'data': 'str' } } >>> { 'type': 'Branch2', 'data': { 'data': 'int' } } >>> { 'union': 'Flat', 'base': 'Base', 'discriminator': 'type', >>> 'data': { 'one': 'Branch1', 'two': 'Branch2' } } >> >> Perhaps we should expose all unions for schema introspection in a way >> similar to this (possibly not splitting out Branch1 and Branch2 as >> independent types, though). We would just have to give a name to >> implicitly generated enums and base types. > > So maybe we update the schema to allow anonymous types. That is: > > { 'union': 'Simple', > 'data': { 'one': { 'name': 'str', 'value': 'int' } } } > > would be nicer than the current requirement of: > > { 'type': 'Branch1', 'data': { 'name': 'str', 'value': 'int' } } > { 'union': 'Simple', > 'data': { 'one': 'Branch1' } } Hmm; maybe we could support a notion of a 'common' dictionary for simple unions, containing all non-discriminator fields present in all branches, where (using anonymous types for compactness), and assuming the enum definition: { 'union': 'Simple', 'common': { 'readonly': 'bool' }, 'data': { 'one': 'str', 'two': 'int' } } is shorthand for: { 'union': 'Flat', 'base': { 'readonly': 'bool', 'type': 'Enum' }, 'discriminator': 'type', 'data': { 'one': { 'data': 'str' }, 'two': { 'data': 'int' } } } that is, where 'base' for flat unions is the union of the 'common' type and 'discriminator':'discriminator-type' member of simple unions. At any rate, any changes along these lines will be a later series. Time for me to get back to work on publishing v6 :) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org