OAI / OAI/OpenAPI-Specification
Add support for templatedRef in Reference Object
Nessuno ha ancora preso questa issue.
- Lingua principale
- Markdown
- Stelle
- 31.2k
- Fork
- 9.2k
- Merge medio
- 6h 37m
- PR unite (30g)
- 27
Descrizione
Proposing to add support for "$templatedRef" to Reference Objects supporting templated references, allowing referencing dynamic schemas that could be retrieved by substituting the template variables by the selected value for earlier path parameters
so that later path parameters can be defined differently based on earlier path parameters.
Example:
"parameters" :
{
"collection-styleId" :
{
"name" : "styleId",
"schema" :
{
"$templatedRef" : "./api/collections-styles/{collectionId}"`
}
}
}
As it was initially suggested that this would require to first extend JSON schema, an initial discussion took place in https://github.com/json-schema-org/json-schema-vocabularies/issues/36 . However reading on https://swagger.io/specification/ that the Reference Object is defined by the JSON Reference, rather than by JSON Schema, it seems that this could rather simply be extended with$templatedRef, following https://tools.ietf.org/html/rfc6570 (or a simpler subset of it).
The {collectionId} template would be replaced by a selected value like collection1.
(e.g. in this example, this "$templatedRef" is used to define the valid values for {styleId} in a path /collections/{collectionId}/styles/{styleId}).
The {collectionId} would have previously been validated against another potentially dynamic list like "$ref" : "./api/collections".
./api/collections would return something like:
{
"type" : "string",
"enum" : [
"collection1",
"collection2",
"collection3"
]
}
and ./api/collection-styles/collection1 would return something like
{
"type" : "string",
"enum" : [
"style234",
"style235",
"style236"
]
}
while ./api/collection-styles/collection2 would return something like
{
"type" : "string",
"enum" : [
"style454",
"style455",
"style456"
]
}
The context being that available/compatibles styles depend on the selected collection.
Such a capability would allow to define much more interoperable APIs, where the specifics of a particular instance / deployment would be left to the templated references. In turn this would allow to automatically generate clients from an API definition that will work with multiple instances of the same templatable API, therefore extending the usability of clients automatically generated from OpenAPI definitions beyond on-the-fly client generation, more suitable for compiled programming languages.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando la definizione di Reference Object, il materiale JSON Reference, RFC 6570 e la discussione collegata sui vocabolari JSON Schema. Il lavoro è completato quando la semantica e l'ambito di $templatedRef sono concordati e specificati con sufficiente chiarezza da supportare gli esempi di collection e style.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Ambito
- api, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100