Lapidary
Python DSL for Web API clients.
Why
DRY. Web API clients follow a relatively small set of patterns and writing them is rather repetitive task. Encoding these patterns in form of a DSL library frees its users from implementing the same patterns over and over again.
How
Lapidary is an internal DSL made of decorators and annotations, that can be used to describe Web APIs similarly to OpenAPI (lapidary-render can convert a large subset of OpenAPI 3.0 to Lapidary).
At runtime, the library interprets user-provided function declarations (without bodies), and makes them behave as declared. If a function accepts parameter of type X and returns Y, Lapidary will try to convert X to HTTP request and the response to Y.
Example:
class CatClient(ClientBase):
"""This class is a working API client"""
def __init__(self):
super().__init__(
base_url='https://example.com/api',
)
@get('/cat')
async def list_cats(self: Self) -> Annotated[
tuple[list[Cat], CatListMeta],
Responses({
'2XX': Response(
Body({
'application/json': list[Cat],
}),
CatListMeta
),
})
]:
pass
client = CatClient()
cats_body, cats_meta = await client.list_cats()
Metadata
Release files for lapidary 0.12.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lapidary-0.12.3.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lapidary-0.12.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.0 kB
Release files / lapidary-0.12.3.tar.gz
| Download URL | lapidary-0.12.3.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70cbb32f2c55adcf7f0d7b6ca3b6b0a9e1414aa18caf887bc6631a11b69bec9f
|
|
BLAKE2b-256 checksum How to use checksums |
bf06e795c72392cc09528cd581373fc5a12e259e9efdc81ee2705ac6adcfa5a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure
|
Release files / lapidary-0.12.3-py3-none-any.whl
| Download URL | lapidary-0.12.3-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a54a2faa64fa4c5afde3de2388d1bee706071764327b33029b6a5804ed414abd
|
|
BLAKE2b-256 checksum How to use checksums |
c509d33ee7b388e10d8dc37c49e5f63962256f3eaf06ef1a761ccbde89a29876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure
|