Skip to content

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

Closed
@baywet

Description

@baywet

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.

Metadata

Metadata

Assignees

Labels

V2-EnhancementWIPpriority:p2Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 daystype:enhancementEnhancement request targeting an existing experience

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions