microsoft / microsoft/OpenAPI.NET.OData
When EnableDiscriminatorValue is set to true all types end up with a required property of odata.type
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 240
- Forks
- 70
- Ø Merge
- 7 Std. 59 Min.
- Gemergte PRs (30 T.)
- 13
Beschreibung
My understanding is odata.type is only required in the case the type cannot be determined such as it being a type derived from the specified type.
When using EnableDiscriminatorValue = true I get correctly odata.type used as a discriminator when a type has a derived type.
I also get however for seemingly all types, odata.type included as a required property.
Assemblies affected
v1.1.0
Steps to reproduce
- Create an odata model with no derived types.
- Generate an Open API specification from the model with EnableDiscriminatorValue = true.
Expected result
I would only expect odata.type to be required in the case a type is a derived type.
Actual result
odata.type is set as required for all types.
If I use Open API connected services in Visual Studio with the specification to generate a client, the client will fail to deserialize responses missing the required property by default.
Additional detail
This can be worked around in most case.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Problem mit einem OData-Modell zu reproduzieren, das keine abgeleiteten Typen hat und bei dem EnableDiscriminatorValue auf true gesetzt ist, und untersuche anschließend die generierte OpenAPI-Spezifikation. Verfolge, wie Discriminator-Metadaten zu einer erforderlichen Eigenschaft werden; abgeschlossen ist die Aufgabe, wenn odata.type nur dort erforderlich ist, wo abgeleitete Typen dies notwendig machen, ohne die gültige Deserialisierung durch Clients zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, openapi
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100