microsoft / microsoft/OpenAPI.NET

Add support for $schema and jsonSchemaDialect

Aperta
#2,963 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

help wanted
Lingua principale
C#
Stelle
1.6k
Fork
286
Merge medio
6h 38m
PR unite (30g)
35

Descrizione

In today's implementation (2.11.0, 3.9.0), the deserialization and serialization of JSON Schemas is effectively hard-coded to 2020-12.

However, starting with OpenAPI 3.1, people can set the $schema property of any given schema to a different dialect (default being documented here.

This entails a couple of things:

  1. parsing that keyword first if it exists, or falling back on the document dialect property, or falling back to the default value for the OpenAPI version.
  2. if that value is known (like https://spec.openapis.org/oas/3.1/dialect/base using the parsing logic associated with that entry
  3. if that value is unknown, we need to load the corresponding schema, and read its schema (recursively) until we find a known value. (note be careful of the security considerations here)

Note: ideally we'd make the OpenAPISchema type generic and allow the caller to provide new registrations of schemas uris with the corresponding parsing logic and data type, but that'd introduce major breaking changes, making the cost prohibitive.

That update will most likely require introducing a JSON Schema service of some kind in charge of mapping the known schemas with their deserialization logic, and having the OpenAPISchema deserializers call into that service.

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.

Direzione di ricerca

Inizia tracciando i deserializzatori e serializzatori di OpenAPISchema e identificando dove viene applicata l’ipotesi 2020-12. Definisci il servizio JSON Schema attorno alla registrazione dei dialetti, alla risoluzione del fallback, alla gestione ricorsiva degli schemi sconosciuti e ai vincoli di sicurezza; il lavoro è completato quando $schema e jsonSchemaDialect selezionano il dialetto noto o caricato corretto senza compromettere il comportamento esistente.

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

Valutazione

Stack tecnologico
csharp, openapi
Ambito
api, backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.