Support validation of Response without providing Request
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- api, backend-api-design
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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?
- Linguagem predominante
- Python
- Estrelas
- 368
- Forks
- 140
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-openapi/openapi-core
-
kind/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python-openapi/openapi-core#1188 · 2 comentários ·
-
kind/bug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
python-openapi/openapi-core#1225 · 2 comentários ·
-
kind/bug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Abertakind/bug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
python-openapi/openapi-core#1180 · 3 comentários ·
Todas as issues de python-openapi/openapi-core
Issues semelhantes
-
sponsored
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Diaoul/subliminal#1382 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
triage/confirmed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
agentscope-ai/agentscope#2775 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100