microsoft-graph-devx-api icon indicating copy to clipboard operation
microsoft-graph-devx-api copied to clipboard

Add x-ms-discriminator support to OpenAPI for PowerShell

Open darrelmiller opened this issue 5 years ago • 8 comments

https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md#x-ms-discriminator-value Should this go in OData.OpenApi reader? Or in OpenAPI.NET v3 -> v2 translation.

Related to: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/19#

darrelmiller avatar Feb 26 '20 19:02 darrelmiller

Add support for x-ms-discriminator here https://github.com/microsoft/OpenAPI.NET/blob/vnext/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs#L49

darrelmiller avatar Mar 09 '20 15:03 darrelmiller

In order to identify derived types we will need to replace all $refs to base types with the following:

 oneOf:  
  - $ref: '#/components/schemas/microsoft.graph.directoryObject'
  - $ref: '#/components/schemas/microsoft.graph.user'
  - $ref: '#/components/schemas/microsoft.graph.group'

darrelmiller avatar Mar 11 '20 21:03 darrelmiller

More details are explained here https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/19

darrelmiller avatar Mar 11 '20 21:03 darrelmiller

@peombwa Is the oneOf essential for enabling discriminators or is it just a nice to have?

darrelmiller avatar Mar 23 '20 14:03 darrelmiller

@darrelmiller It is not essential. We can enable it by having the discriminator object on the base type and x-ms-discriminator-value on the derived type. Since the value of the OData.Type starts with a #, we need to have x-ms-discriminator-value on the derived type with its OData.Type value. e.g. #microsoft.graph.user.

peombwa avatar Mar 23 '20 18:03 peombwa

Reopening this so we can investigate the feasibility of using the DerivedTypeConstraint that was added to in https://github.com/microsoftgraph/msgraph-metadata/pull/33 to pull in all the derived types of a base type.

peombwa avatar Mar 31 '22 22:03 peombwa

@peombwa do we still need this?

adhiambovivian avatar Aug 24 '22 13:08 adhiambovivian

Yes, we do @adhiambovivian . We need this to be supported so we can have discriminator support in PS SDK.

maisarissi avatar Sep 20 '22 15:09 maisarissi