Django integration is incompatible with Django REST Framework

Abierto
#247 0 comentarios 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
django, python
Área
api, backend

Línea de trabajo

Review the DjangoOpenAPIRequest class and the linked Django REST Framework issue first. Compare request.body and request.data behavior for a DRF Request, then determine an integration approach; done means DRF requests no longer fail because POST data is read twice.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area/contrib help wanted

The DjangoOpenAPIRequest class accesses request.body. This can cause issues related to reading the POST data twice, as described here:

https://github.com/encode/django-rest-framework/issues/2774

I have found that DRF accesses the request.body to read the CSRF token so the mitigation steps described in the issue above do not work. I have a branch of openapi-core here:

https://github.com/jrtcppv/openapi-core

That instead reads request.data and bypasses the deserialization of the request body. This is probably not the right solution as it is, but it might be possible to inspect the type of the request and do something different if it is not a normal django HttpRequest class, but rather the Request class provided by DRF.

I also tried subclassing DRF's APIView and overriding the intialize_request function, returning a subclass of Request that contained the parameters parsed by openapi-core. This also worked and might be an option if there needs to be a separate integration just for DRF.

Anyway, thanks for the library!

Lenguaje dominante
Python
Estrellas
368
Forks
140
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-openapi/openapi-core

Todos los issues de python-openapi/openapi-core

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.