pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
127 stars 34 forks source link

Default discriminator values #647

Open jfawcett2000 opened 3 years ago

jfawcett2000 commented 3 years ago

The comment on the OdataType property of the ForwardingConfigurationArgs reads:

"Expected value is '#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration'."

Please either make it private or readonly, as it's unnecessary for consumers to have to set this required value themselves.

stack72 commented 2 years ago

The potential work here is to be able to create schema plumbing that allows us to set default values for specific parameters for specific resources

danielrbradley commented 2 years ago

The OpenAPI specifications support a field in types called discriminator. This is the name of the field used to discriminate the type when serialized. This is normally a required field e.g. @odata.type and can be set in a common 'base' type which is included into multiple other types e.g. RouteConfiguration is included into ForwardingConfiguration in frontdoor.json.

If, in the subtype, x-ms-discriminator-value is specified, we should make the 'discriminator' value optional and set a default value in the provider. This could be implemented with the condition that the descriminator type is a string (or string enum) as this the case in all examples seen so far.