godto
Data Transfer Object (DTO) codegen from JSON schemas following the OpenAPI spec
Usage
Full OpenAPI schema model
To work with an OpenAPI schema, load it with the Model class,
which is a Pydantic model (however note that the class name 'Model' comes from the OpenAPI spec).
from godto.openapi.v3 import Model
model = Model.parse_raw(schema_json)
For example the Transport for London StopPoint API schema
is shipped as package data in tubeulator.
from pathlib import Path
path_to_schema = Path("data/openapi/StopPoint/StopPoint.json")
schema_json = path_to_schema.read_text()
Model helper functions
You can also work with partial views on the model, such as the paths and their parameters.
The examples in the following code block show model_paths which loads the schema for a given spec
(by default OpenAPI v3) and returns its parameters for a specific method (by default GET):
required: whether the parameter is required or optionalschema_: the schema for parsing the parameterdescription: the human-readable parameter docstring
>>> from godto.api.model import model_paths
>>> param_requirements = model_paths(schema_json, extract="required")
>>> pprint(param_requirements)
{'/': {'categories': False,
'lat': True,
'lon': True,
'modes': False,
'radius': False,
'returnLines': False,
'stopTypes': True,
'useStopPointHierarchy': False},
'/*': {},
'/Meta/Categories': {},
'/Meta/Modes': {},
...
>>> param_schemas = model_paths(schema_json, extract="schema_")
>>> param_descs = model_paths(schema_json, extract="description")
>>> pprint(param_descs)
>>> pprint(param_descs)
{'/': {'categories': 'an optional list of comma separated property categories '
"to return in the StopPoint's property bag. If null or "
'empty, all categories of property are returned. Pass the '
'keyword "none" to return no properties (a valid list of '
'categories can be obtained from the '
'/StopPoint/Meta/categories endpoint)',
'lat': 'Format - double. the latitude of the centre of the bounding '
'circle',
'lon': 'Format - double. the longitude of the centre of the bounding '
'circle',
'modes': 'the list of modes to search (comma separated mode names e.g. '
'tube,dlr)',
'radius': 'Format - int32. the radius of the bounding circle in metres '
'(default : 200)',
...
Requirements
Python 3.9+
Metadata
Release files for godto 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| godto-0.0.5.tar.gz | 18.9 kB | Without provenance | Details for godto-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| godto-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for godto-0.0.5-py3-none-any.whl |
Total release size: 38.0 kB
Release files / godto-0.0.5.tar.gz
| Download URL | godto-0.0.5.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1d7f7b78a6841a05eb3fff7f6940bda3396ad8041a3be9d0d22518362b42b6e
|
|
BLAKE2b-256 checksum How to use checksums |
497f10cfd31573fe510033eb8067a5ef43a3faaeae72b601a74ace8b0fc47edb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / godto-0.0.5-py3-none-any.whl
| Download URL | godto-0.0.5-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f24115fd5c0f01cd2079bbc50cbc18ad66c7e447f7e7f72d1c591c072d525de
|
|
BLAKE2b-256 checksum How to use checksums |
dfb5ec144873a5da2b5a18a4eb3295c9221d68d7b70ac34e841a4002a1ec486a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for godto 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.