openapi-generators / openapi-generators/openapi-python-client
TypeError when model default value is a list
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 2k
- Forks
- 293
- Merge médio
- 34min
- PRs com merge (30d)
- 1
Descrição
Describe the bug
When generating models for an API where a default argument is a list of enums, a TypeError is raised on this line:
return f"{prop.class_info.name}.{inverse_values[default]}"
A possible fix could be to explicitly check for this case. Below is a proposed fix, but I'm not familiar enough with the codebase to know whether this is a correct fix. However, I was able to parse the API docs correctly with this fix in place:
if type(default) is list:
return [f"prop.class_info.name.inverse_values[d]" for d in default]
else:
return f"{prop.class_info.name}.{inverse_values[default]}"
To Reproduce
Steps to reproduce the behavior:
- Run
openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml - See error
Expected behavior
The API docs should be able to be parsed
OpenAPI Spec File
https://sand-docs.ilevelsolutions.eu/openapi.yaml
Desktop (please complete the following information):
- OS: macOS 13.1
- Python Version: 3.10
- openapi-python-client version: 0.13.1
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.
Direção de pesquisa
Comece em openapi_python_client/parser/properties/init.py por volta da linha 463 e reproduza a falha com openapi-python-client generate --url https://sand-docs.ilevelsolutions.eu/openapi.yaml. Rastreie como os valores padrão de enum com valores de lista são representados e verifique os testes relevantes do parser. Considera-se concluído quando a especificação for gerada com sucesso sem o TypeError e o comportamento existente permanecer intacto.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- openapi, python
- Domínio
- api, tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 65/100