Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all derived types in discriminator mapping and append @odata.type property to all derived types #256

Merged
merged 2 commits into from
Jul 18, 2022

Conversation

irvinesunday
Copy link
Contributor

Fixes #248
Fixes #240

This PR:

  • Finds all derived types for a given type and adds this to the discriminator mapping.
  • Appends the @odata.type property to the derived types, and marks this as a required property.
  • Updates tests to validate the above.
  • Bumps library package to v1.0.11 and add release notes.

The generated OpenAPI document with the above changes looks like below for:

microsoft.graph.fileAttachment

image

microsoft.graph.mobileApp

microsoft.graph.mobileApp:
      allOf:
        - $ref: '#/components/schemas/microsoft.graph.entity'
        - title: mobileApp
          required:
            - '@odata.type'
          type: object
          properties:
            ..........
           
            '@odata.type':
              type: string
              default: '#microsoft.graph.mobileApp'
          description: An abstract class containing the base properties for Intune mobile apps.
          discriminator:
            propertyName: '@odata.type'
            mapping:
              '#microsoft.graph.mobileLobApp': '#/components/schemas/microsoft.graph.mobileLobApp'
              '#microsoft.graph.androidLobApp': '#/components/schemas/microsoft.graph.androidLobApp'
              '#microsoft.graph.iosLobApp': '#/components/schemas/microsoft.graph.iosLobApp'
              '#microsoft.graph.win32LobApp': '#/components/schemas/microsoft.graph.win32LobApp'
              '#microsoft.graph.windowsMobileMSI': '#/components/schemas/microsoft.graph.windowsMobileMSI'
              '#microsoft.graph.windowsUniversalAppX': '#/components/schemas/microsoft.graph.windowsUniversalAppX'
              '#microsoft.graph.androidStoreApp': '#/components/schemas/microsoft.graph.androidStoreApp'
              '#microsoft.graph.iosStoreApp': '#/components/schemas/microsoft.graph.iosStoreApp'
              '#microsoft.graph.iosVppApp': '#/components/schemas/microsoft.graph.iosVppApp'
              '#microsoft.graph.macOSOfficeSuiteApp': '#/components/schemas/microsoft.graph.macOSOfficeSuiteApp'
              '#microsoft.graph.managedApp': '#/components/schemas/microsoft.graph.managedApp'
              '#microsoft.graph.managedMobileLobApp': '#/components/schemas/microsoft.graph.managedMobileLobApp'
              '#microsoft.graph.managedAndroidLobApp': '#/components/schemas/microsoft.graph.managedAndroidLobApp'
              '#microsoft.graph.managedIOSLobApp': '#/components/schemas/microsoft.graph.managedIOSLobApp'
              '#microsoft.graph.managedAndroidStoreApp': '#/components/schemas/microsoft.graph.managedAndroidStoreApp'
              '#microsoft.graph.managedIOSStoreApp': '#/components/schemas/microsoft.graph.managedIOSStoreApp'
              '#microsoft.graph.microsoftStoreForBusinessApp': '#/components/schemas/microsoft.graph.microsoftStoreForBusinessApp'
              '#microsoft.graph.webApp': '#/components/schemas/microsoft.graph.webApp'

and...

microsoft.graph.mobileLobApp

microsoft.graph.mobileLobApp:
      allOf:
        - $ref: '#/components/schemas/microsoft.graph.mobileApp'
        - title: mobileLobApp
          required:
            - '@odata.type'
          type: object
          properties:
            ..................

            '@odata.type':
              type: string
              default: '#microsoft.graph.mobileLobApp'
          description: An abstract base class containing properties for all mobile line of business apps.
          discriminator:
            propertyName: '@odata.type'
            mapping:
              '#microsoft.graph.androidLobApp': '#/components/schemas/microsoft.graph.androidLobApp'
              '#microsoft.graph.iosLobApp': '#/components/schemas/microsoft.graph.iosLobApp'
              '#microsoft.graph.win32LobApp': '#/components/schemas/microsoft.graph.win32LobApp'
              '#microsoft.graph.windowsMobileMSI': '#/components/schemas/microsoft.graph.windowsMobileMSI'
              '#microsoft.graph.windowsUniversalAppX': '#/components/schemas/microsoft.graph.windowsUniversalAppX'

Copy link
Member

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

@irvinesunday irvinesunday merged commit bf2803d into master Jul 18, 2022
@irvinesunday irvinesunday deleted the fix/is/derived-types-fix branch July 18, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some types missing default values for @odata.type Discriminator mapping should list all derived types
3 participants