0.9.0
Lapidary 0.9.0 is pretty much a new library.
Now it's more of a DSL capable of describing a Web API in a manner similar to OpenAPI 3.0,
from typing import Annotated, Self
from lapidary.runtime import *
# Define models
class Cat(ModelBase):
id: int
name: str
# Declare the client
class CatClient(ClientBase):
def __init__(
self,
base_url='http://localhost:8080/api',
):
super().__init__(base_url=base_url)
@get('/cat/{id}')
async def cat_get(
self: Self,
*,
id: Annotated[int, Path(style=ParamStyle.simple)],
) -> Annotated[Cat, Responses({
'2XX': {
'application/json': Cat
},
})]:
pass
# User code
async def main():
client = CatClient()
cat = await client.cat_get(id=7)