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

v2 - discriminator mappings should be dictionary<string, OpenApiSchemaReference> #2140

Open
baywet opened this issue Feb 11, 2025 · 0 comments
Labels
priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days type:enhancement Enhancement request targeting an existing experience V2-Enhancement
Milestone

Comments

@baywet
Copy link
Member

baywet commented Feb 11, 2025

Now that we've fixed the references behaviour, I believe that Discriminator mappings should be a Dictionary<string, OpenApiSchemaReference> instead of <string, string>

so currently

Discriminator = new()
            {
                PropertyName = "@odata.type",
                Mapping = new Dictionary<string, string> {
                    {
                        "#microsoft.graph.directoryObject", "#/components/schemas/microsoft.graph.directoryObject"
                    },
                    {
                        "#microsoft.graph.file", "#/components/schemas/microsoft.graph.file"
                    }
                }
            },

tomorrow

Discriminator = new()
            {
                PropertyName = "@odata.type",
                Mapping = new Dictionary<string, string> {
                    {
                        "#microsoft.graph.directoryObject", new OpenApiSchemaReference("microsoft.graph.directoryObject")
                    },
                    {
                        "#microsoft.graph.file", new OpenApiSchemaReference("microsoft.graph.file")
                    }
                }
            },

There are a number of reasons for doing that:

  1. the syntax of the references (#/components/schemas) varies between v2 and v3, and might vary in v4. And we shouldn't expect the user to know about that/have to change it between different serialization versions.
  2. using references would bring the resolution logic in place which would not only improve checking for document integrity but also let the user navigate to the target from the object model.

Before we do any work on that, I'd like @darrelmiller to chime in.

@baywet baywet added type:enhancement Enhancement request targeting an existing experience V2-Enhancement priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days labels Feb 11, 2025
@baywet baywet added this to the v2 - Preview9 milestone Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days type:enhancement Enhancement request targeting an existing experience V2-Enhancement
Projects
None yet
Development

No branches or pull requests

1 participant