microsoft / microsoft/OpenAPI.NET
Add support for $schema and jsonSchemaDialect
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 1.6k
- Forks
- 286
- Merge moyen
- 6 h 38 min
- PR mergées (30 j)
- 35
Description
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:
- 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.
- if that value is known (like
https://spec.openapis.org/oas/3.1/dialect/baseusing the parsing logic associated with that entry - 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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par suivre les désérialiseurs et sérialiseurs de OpenAPISchema et identifier où l’hypothèse 2020-12 est appliquée. Définissez le service JSON Schema autour de l’enregistrement des dialectes, de la résolution du fallback, de la gestion récursive des schémas inconnus et des contraintes de sécurité ; le travail est terminé lorsque $schema et jsonSchemaDialect sélectionnent le dialecte connu ou chargé correct sans modifier le comportement existant.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, openapi
- Domaine
- api, backend-api-design
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100