msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

New-MgEntitlementManagementAccessPackageAssignmentRequest - case sensitivity issue with properties

Open FaithOmbongi opened this issue 3 years ago • 2 comments

As per this customer issue https://github.com/microsoftgraph/microsoft-graph-docs/issues/17798, the "Value" property required in the PowerShell snippet of Example 2 in the Graph API docs is case-sensitive. Please see more here 👇🏾

The issue is with the PowerShell example.

image

My suggestion to the engineering team would be to be consistent throughout, as all other properties in the PS sample are not case-sensitive.

Kindly assist to resolve this problem.

First raised by @pettewayshade

cc @msewaweru, @markwahl-msft, @peombwa

FaithOmbongi avatar Jul 25 '22 07:07 FaithOmbongi

There was an thread with @darrelmiller on February 15, 2022 on a related issue with named location. "The PowerShell cmdlets should be sending the property names with the correct casing. I suspect the reason why they are not getting cased correctly is because the properties are defined in the derived type. When the payload is getting serialized, the properties that exist in namedLocation are getting the correct casing but the properties that are in ipNamedLocation are not..."

markwahl-msft avatar Jul 25 '22 15:07 markwahl-msft

The issue is due to missing derived types in the OpenAPI document and lack of discriminator support.

accessPackageAnswerString is a derived type accessPackageAnswer abstract type:

<ComplexType Name="accessPackageAnswer" Abstract="true">
  <Property Name="answeredQuestion" Type="graph.accessPackageQuestion" />
  <Property Name="displayValue" Type="Edm.String" />
</ComplexType>
<ComplexType Name="accessPackageAnswerString" BaseType="graph.accessPackageAnswer">
  <Property Name="value" Type="Edm.String" />
</ComplexType>

The derived type is missing in the OpenAPI used to generate the module:

microsoft.graph.accessPackageAnswer:
  title: accessPackageAnswer
  type: object
  properties:
    answeredQuestion:
      $ref: '#/components/schemas/microsoft.graph.accessPackageQuestion'
    displayValue:
      type: string
      description: The display value of the answer. Required.
      nullable: true
  additionalProperties:
    type: object

This makes AutoREST.PowerShell to serialize the property as an "additional property" which is case sensitive.

The ideal OpenAPI representation of the polymorphic schema should be something like this:

microsoft.graph.accessPackageAnswer:
  title: accessPackageAnswer
  required:
    - '@odata.type'
  type: object
  properties:
    answeredQuestion:
      anyOf:
        - $ref: '#/components/schemas/microsoft.graph.accessPackageQuestion'
        - type: object
          nullable: true
      description: The question the answer is for. Required and Read-only.
    displayValue:
      type: string
      description: The display value of the answer. Required.
      nullable: true
    '@odata.type':
      type: string
      default: '#microsoft.graph.accessPackageAnswer'
  discriminator:
    propertyName: '@odata.type'
    mapping:
      '#microsoft.graph.accessPackageAnswerString': '#/components/schemas/microsoft.graph.accessPackageAnswerString'

Discriminator support is dependent on https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/196.

cc\ @maisarissi for prioritization.

peombwa avatar Jul 25 '22 15:07 peombwa

Closing as duplicate of https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/19#issuecomment-595575996.

Discriminator support will be handled in v3 when we move to a new code generator. The current code generator is not capable of generating cmdlets that handle OpenAPI discriminator.

peombwa avatar Jun 19 '23 23:06 peombwa