Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

379
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!