Support validation of Response without providing Request
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- api, backend-api-design
Direzione di ricerca
Start with ResponseValidator in openapi_core.validation.response.validators and read the response-validation examples, then compare the validator code with the refactoring mentioned on the master branch. The work is complete when the documented validation flow can handle a response without the caller supplying a request, with its operation and method requirements defined and tested.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi,
I was planning on using the (Django REST Framework) Response validation in some unit tests. These unit tests are performing different actions on the REST API and validate the result. I would like to validate the response against the schema as well.
The problem is, all the django unit tests are based on having a self.client that is called to performing actions using response = self.client.post()..., response = self.client.get(...), etc.
So I don't have access to the request that was sent, so I can't use the pattern provided in the examples:
from openapi_core.validation.response.validators import ResponseValidator
validator = ResponseValidator(spec)
result = validator.validate(request, response)
# raise errors if response invalid
result.raise_for_errors()
# get list of errors
errors = result.errors
I went through the validator code and from what I can see now the request object is mainly used to determine which operation & method was executed. I also see there's some refactoring going on on the master branch.
Is there any way to validate the response, without providing the request object?
I tried to make a "mock" request object, but I don't know enough about the (Django) request internals yet to know what attributes and values to set.
I am also interested to know how others are using the validation. Are you using it server site as some (Django) middleware that checks requests/responses?
- Lingua principale
- Python
- Stelle
- 368
- Fork
- 140
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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.
Altre issue di python-openapi/openapi-core
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python-openapi/openapi-core#1188 · 2 commenti ·
-
kind/bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
python-openapi/openapi-core#1225 · 2 commenti ·
-
kind/bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Apertakind/bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
python-openapi/openapi-core#1180 · 3 commenti ·
Tutte le issue di python-openapi/openapi-core
Issue simili
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
apache/cloudstack#14222 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100