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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9b41d367b4a663f461f5515048a05ffb52db481f0ea20d1dbe363b6834e2174
|
|
| MD5 |
56a703e9d23f767a7f5e5fb5f3ad81f5
|
|
| BLAKE2b-256 |
5cc8c14d42fcaa2100f75bd862a6f5afbe8ea77c561211a597d6e6925d82cfa3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b77253bdc815c37e0469ce191f35c265dc827b0d830758bb099ea78b3bc10ec9
|
|
| MD5 |
de5df8f7464895aa7a7fd1098f76874c
|
|
| BLAKE2b-256 |
0d8270391005ed6e9ec2313821f599c2df5bc46ceb86eb131a0af66f9341f6a8
|