Python async OpenAPI client library generator
Project description
Code generator
Installation
lapidary-render requires python 3.9 or higher to run.
I recommend installing via pipx
pipx install lapidary-render
You can set python version for lapidary with pipx install --python [path-to-python] lapidary-render
. See pipx install --help
for details.
Usage
lapidary
command offers inline help and shell command completion. See lapidary --help
for details.
lapidary init
lapidary init [--[no-]format-strict] [--[no-]render] SCHEMA_PATH PROJECT_ROOT PACKAGE_NAME
Lapidary will create
- PROJECT_ROOT and all necessary directories,
- __init__.py files,
- pyproject.toml with poetry configured,
- py.typed
- client.pyi with function stubs for all operations and a client.py with an empty client class.
- Pydantic model classes for each schema.
All python files are generated in PROJECT_ROOT/gen directory.
If a directory PROJECT_ROOT/src/patches exists, Lapidary will read all yaml files and apply them as JSONPatch against the original openapi file.
If the original openapi file is not compatible with Lapidary, running lapidary init --no-render ...
will generate only the project structure without any
models or stubs. Once you've prepared the patch, run lapidary update
.
lapidary update
lapidary update [--[no-]format-strict] [--[no-]cache] [PROJECT_ROOT]
Default PROJECT_ROOT is the current directory.
The command
- deletes PROJECT_ROOT/gen directory,
- re-applies patches to openapi file
- and generates python files
lapidary version
lapidary version
Prints the programs version and exits.
Configuration
Lapidary can be configured with a pyproject.yaml file, under [tool.lapidary] path.
Only package
value is required, and it's set by lapidary init
.
- package [str] - root package name
- format [bool] - whether to format the generated code with black [default = True].
- cache [bool] - whether to cache openapi and patches as pickle files. Only files larger than 50kB are cached [default = True].
- src_root [str] - sources root, in PROJECT_ROOT [default = 'src'].
- gen_root [str] = generated sources root, in PROJECT_ROOT [default = 'gen'].
- patches [str] = patches directory, under sources root [default = 'patches'].
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
Hashes for lapidary_render-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4059e3a99308b73e19234b76c5f199857753b9fe9386ca7860fd92c49ffb1f9a |
|
MD5 | 4e340ab14333fa3cbd696104fa4c4b27 |
|
BLAKE2b-256 | 59db7303ba50c2004a3e4eec10189bdf2bd3a01debcafc82524190efdb668c1f |