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.2.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.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: npdi_oas-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d9b41d367b4a663f461f5515048a05ffb52db481f0ea20d1dbe363b6834e2174
MD5 56a703e9d23f767a7f5e5fb5f3ad81f5
BLAKE2b-256 5cc8c14d42fcaa2100f75bd862a6f5afbe8ea77c561211a597d6e6925d82cfa3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: npdi_oas-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b77253bdc815c37e0469ce191f35c265dc827b0d830758bb099ea78b3bc10ec9
MD5 de5df8f7464895aa7a7fd1098f76874c
BLAKE2b-256 0d8270391005ed6e9ec2313821f599c2df5bc46ceb86eb131a0af66f9341f6a8

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