Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Support xs-ms-enum values without the "value" label

Aperta
#216 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
api, devtools

Direzione di ricerca

Inizia esaminando XmsEnumExtension e XmsEnumValue, quindi riproduci l’errore di deserializzazione di Newtonsoft.Json con il JSON x-ms-enum mostrato nel percorso di confronto di OpenApi-Diff. Il lavoro è completato quando le voci dell’enum rappresentate come valori primitivi, inclusi 3, 4 e 5, vengono deserializzate e confrontate senza generare una JsonSerializationException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Some contract generators define the values of x-ms-enum as a list of actual values without labels.
The current version OpenApi-Diff doesn't support this format and throws a Newtonsoft.Json.JsonSerializationException in this case.

Example of x-ms-enum with and without the "value" label
"enum": [ "Mammals", "Fish", "Birds", "Reptiles", "Amphibians", "Invertebrates" ], "type": "string", "x-ms-enum": { "name": "PetType", "modelAsString": false, "values": [ { "value": 0, "description": "humans and all other animals that are warm-blooded vertebrates", "name": "Mammals" }, { "value": 1, "description": "aquatic, craniate, gill-bearing animals that lack limbs with digits" }, { "value": 2, "name": "Birds" }, 3, 4, 5 ], "x-nullable": false }

The issue with this XmsEnumExtension is that we cannot cast an object of primitive type (e.g. long, string) to a XmsEnumValue , thus all contracts that contains x-ms-enum with a list of values of primitive type causes a deserialization issue in the OpenApiDiff comparison.

The exception is the following

Newtonsoft.Json.JsonSerializationException : Error converting value 3 to type 'AutoRest.Swagger.Model.XmsEnumValue'. Path 'definitions.PetType.x-ms-enum.values[0]', line 235, position 11.
  ----> System.ArgumentException : Could not cast or convert from System.Int64 to AutoRest.Swagger.Model.XmsEnumValue.
Lingua principale
C#
Stelle
290
Fork
50
Merge medio
2g 21h
PR unite (30g)
10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/openapi-diff

Tutte le issue di Azure/openapi-diff

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.