On 11/04/2013 05:37 PM, Wenchao Xia wrote: > It will check whether the values specfied are wrotten correctly when
s/specfied/specified/
s/wrotten/written/
> discriminator is a pre-defined enum type, which help check whether the
> schema is in good form.
>
> It is allowed that, not every value in enum is used, so do not check
s/that,/that/
> that case.
Why do you allow partial coverage? That feels like an accident waiting
to happen. Does the user get a sane error message if they request an
enum value that wasn't mapped to a union branch? I think it would be
wiser to mandate that if the discriminator is an enum, then the union
must cover all values of the enum.
> +
> +# Return the descriminator enum define, if discriminator is specified in
s/descriminator/discriminator/
> +# @expr and it is a pre-defined enum type
> +def descriminator_find_enum_define(expr):
s/descriminator/discriminator/ - and fix all callers
> + discriminator = expr.get('discriminator')
> + base = expr.get('base')
> +
> + # Only support discriminator when base present
> + if not (discriminator and base):
> + return None
> +
> + base_fields = find_base_fields(base)
> +
> + if not base_fields:
> + sys.stderr.write("Base '%s' is not a valid type\n"
> + % base)
> + sys.exit(1)
> +
> + descriminator_type = base_fields.get(discriminator)
s/descriminator/discriminator/
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
