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.4.tar.gz (7.1 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.4-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: npdi_oas-0.0.4.tar.gz
  • Upload date:
  • Size: 7.1 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.4.tar.gz
Algorithm Hash digest
SHA256 d32cf430f4c3975ebd9111004da471188332bf89eeb95b9c3307c1b3d91e8517
MD5 bd35f0141d890635738823031cb1674f
BLAKE2b-256 30da2a9bb6002a50a64d9e8bbfc560061b3b2793cefac29dfd41ed8e4000cdb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: npdi_oas-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2421a1fca08a9902c36b13d45646b82c2f499b2e2d7efe28baec557e72a3b28f
MD5 faaae31938c2e2f1162ef90e0ad9f08e
BLAKE2b-256 5a628f96f79b7fa72b7a59626150a71ce008e25438040ebc4be9fc96df472c36

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