openapi-generators / openapi-generators/openapi-python-client
body type mismatch
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 2k
- Forks
- 293
- Merge medio
- 34 min
- PR fusionados (30 d)
- 1
Descripción
Describe the bug
In the _get_kwargs generated method, the body is determined as File type (because the format in my swagger definition is binary), but it tries to access its .to_dict attribute (because body_type is considered as data due to the content type application/x-www-form-urlencoded), which does not exist because it is a file
OpenAPI Spec File
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"description": "do stuff",
"type": "string",
"format": "binary"
}
}
}
Desktop (please complete the following information):
- OS: macOS 13.3.1
- Python Version: 3.9.8
- openapi-python-client version: 0.17.2
Additional context
In the macro, the arguments macro determine the argument type of body based on endpoint.bodies[0].prop.get_type_string(), whereas in the body_to_kwarg macro it determines it based on body.body_type, which is determined by the following:
if simplified_content_type == "application/x-www-form-urlencoded":
body_type = BodyType.DATA
elif simplified_content_type == "multipart/form-data":
body_type = BodyType.FILES
elif simplified_content_type == "application/octet-stream":
body_type = BodyType.CONTENT
elif simplified_content_type == "application/json" or simplified_content_type.endswith("+json"):
body_type = BodyType.JSON
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Start with the generated _get_kwargs method and trace the arguments and body_to_kwarg macros, especially how endpoint.bodies[0].prop.get_type_string() differs from body.body_type. Review the application/x-www-form-urlencoded BodyType mapping and verify that a binary body no longer attempts to access .to_dict.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100