Skip to main content

OpenAPI spec for NPDI data models

Project description

NPDI OAS Schemas

How to Use OAS to Pydantic

The OAS specifications can be used to generate the Pydantic models that validate updates to the database.

Running the Script

  • Basic usage:
    python generate_pydantic_models.py path_to_your_oas.yaml generated_models.py
    
  • With verbose output:
    python generate_pydantic_models.py path_to_your_oas.yaml generated_models.py --verbose
    

Example Usage

python generate_pydantic_models.py models/agencies.yaml pydantic/agencies.py --verbose

Output:

Loaded OpenAPI Specification from 'models/agencies.yaml'.
Generating model code for BaseAgency
Generating model code for CreateAgency
Generating model code for UpdateAgency
Generating model code for AgencyList
Generating model code for Agency
Generating model code for CreateUnit
Generating model code for UpdateUnit
Generating model code for BaseUnit
Generating model code for Unit
Generating model code for UnitList
Generating model code for AddOfficer
Generating model code for AddOfficerList
Generating model code for AddOfficerFailed
Generating model code for AddOfficerResponse
Pydantic models have been successfully generated and saved to 'src_gen/agencies.py'.

Caveats

Polymorphism

The converter doesn't handle polymorphic properties yet. There's been a bit of effort put into making sure it can follow 'allOf' references, but I haven't done any investigation into how it handles 'oneOf' refs. For example, SourceDetails on complaints.

External File References

The generator only looks at one file at a time. It will not follow references to other files. The generator currently just assumes that those references exist and are valid.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

npdi_oas-0.0.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

npdi_oas-0.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file npdi_oas-0.0.1.tar.gz.

File metadata

  • Download URL: npdi_oas-0.0.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for npdi_oas-0.0.1.tar.gz
Algorithm Hash digest
SHA256 235650ada19fd44be3916aeafe081678f8c0ac3042b515c5000946ff8ca7d34e
MD5 4c705107f1592ad80b823ef4691a1a8f
BLAKE2b-256 9ea6faad8634d82db0643712c4350882daf9c6cfb9e0d4095409cdbd22def533

See more details on using hashes here.

File details

Details for the file npdi_oas-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: npdi_oas-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for npdi_oas-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45af1cc44a366f9e92764bde5845112e069ae1427abc0d8ccef2419b0a0b931c
MD5 cdea01b5f9e91c70ef79c19d9fc4e8ba
BLAKE2b-256 11b9750b84edc1b14f83fc00fd0232b6f0279f602b72e679c8f80bfccbe7148d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page