lapis-gen

Python API client generator


Keywords
api-client, domain-specific-language, dsl, openapi, openapi3, python, python3
License
AGPL-3.0
Install
pip install lapis-gen==0.1.2

Documentation

Lapidary

test

Python DSL for Web API clients.

http://lapidary.dev/

Also check lapidary-render, a command line program that generates Lapidary clients from OpenAPI.

Usage:

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()