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

Feature request: allow a reference registry to have a fixed base_uri when the schema does not set `"$id"`

Aperta
#1,547 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python

Direzione di ricerca

Inizia tracciando Validator._resolver e reference_registry.resolver(base_uri=...), quindi esamina come Resource.id() e le interfacce di riferimento gestiscono gli schemi senza "$id". Confronta il comportamento descritto in check-jsonschema#640 e identifica i confini dell’API pubblica che richiederebbero una copertura. Il lavoro è completato quando è possibile impostare un URI di base esplicito senza mutare gli schemi di input né fare affidamento su attributi privati.

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

Descrizione

I'm working on fixing python-jsonschema/check-jsonschema#640 , which is a bit of weirdness to do with local schemas and multiple relative $ref values.

Right now, check-jsonschema is doing some path joining logic to combine the file URI for the input schema with the $ref paths it sees, and it ends up playing out incorrectly when combined with referencing's inner resolver object. Second order ref retrieval does some path joining, which then joins improperly with the explicit base URI.

I found that the issue can be resolved by replacing the Validator._resolver with one that has a non-"" base URL:

        if validator._resolver._base_uri == "" and retrieval_uri is not None:
            validator._resolver = reference_registry.resolver(base_uri=retrieval_uri)

(where retrieval_uri is, in this case, the local file URI)

I don't see an obvious public-API way of doing this. The above is a workaround, and I'll probably do a version of it with some safeguard around potential jsonschema and referencing changes. I rejected my other options as being worse workarounds:

  • modifying the input schema to set "$id" -- although this has the right effect, it strikes me as incorrect (I'm not able to substantiate that with some case in which there's a bad outcome, but it's silently tweaking the user's data to make things work; feels weird IMO)
  • subclassing Resource from referencing to override id() ... based on jsonschema's interfaces, I strongly suspect that this is not intended usage

What would work best is to have some public API way of explicitly setting the base URI for resolution. It probably needs support in referencing, but it also potentially needs to be exposed in jsonschema.

Lingua principale
Python
Stelle
5k
Fork
694
Merge medio
1g 20h
PR unite (30g)
6

Preparare l'ambiente

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 python-jsonschema/jsonschema

Tutte le issue di python-jsonschema/jsonschema

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.