Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

381
Visualizações
list of dicts swagger python

I want to specify a List of dict and the keys of that dicts also in my swagger documentation,

class GetCustomerDetailsByIdPOUT(BaseModel):
    profileData: Customer
    scanData : Reports
    Scan: list
 

Currently, I am getting this

 "Scan": [
    "string"
  ]

You can also see in the image

enter image description here

I want something like this

"scans": [
                {
                "id": 0,
                "cameraId": 0,
                "reportId": 0,
                "sequenceNo": 1,
                "raw": [
                    "string"
                ],
                "spectrum": 1,
                "view": 1
                }
            ]
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think that you don't provide the information on what list will contain. I don't know what you want to have in there, but for example:

from typing import List

class GetCustomerDetailsByIdPOUT(BaseModel):
    profileData: Customer
    scanData : Reports
    Scan: List[MyScan]

within the type hinting you can provide the type - you class or build-in type, like List[float].

For python <= 3.8 you should use typing module, for 3.9+ you don't have to. More on typing aliases.

Also, if possible, think of aligning your naming convention to PEP8. For example profileData -> profile_data.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda