lapidary


Namelapidary JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://github.com/python-lapidary/lapidary
SummaryPython async OpenAPI client library
upload_time2024-06-02 21:56:37
maintainerNone
docs_urlNone
authorRaphael Krupinski
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![test](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml/badge.svg)](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml)

# Lapidary

Python DSL for Web API clients.

Also check [lapidary-render](https://github.com/python-lapidary/lapidary-render/),
a command line program that generates Lapidary clients from OpenAPI.

## Features

- [x] Write Web API clients declaratively
- [x] Use pydantic models for JSON data
- [ ] Compatibility with OpenAPI 3.0 and 3.1

## Installation

```console
pip install lapidary
```

or with Poetry

```console
poetry add lapidary
```

## Usage

With Lapidary, you define an API client by creating a class that mirrors the API structure, akin to OpenAPI but through
decorated and annotated Python methods. Calling these method handles making HTTP requests and transforming the responses
back into Python objects.

```python
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)
```

See [this test file](https://github.com/python-lapidary/lapidary/blob/develop/tests/test_client.py) for a working
example.

[Full documentation](https://lapidary.dev)

Also check the [library of clients](https://github.com/orgs/lapidary-library/repositories).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/python-lapidary/lapidary",
    "name": "lapidary",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Raphael Krupinski",
    "author_email": "rafalkrupinski@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/97/8a/19739814dcbc0f84b2bcc5475ecdc58cc136df6e3344d83cb882b5f9e4bf/lapidary-0.10.0.tar.gz",
    "platform": null,
    "description": "[![test](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml/badge.svg)](https://github.com/python-lapidary/lapidary/actions/workflows/test.yaml)\n\n# Lapidary\n\nPython DSL for Web API clients.\n\nAlso check [lapidary-render](https://github.com/python-lapidary/lapidary-render/),\na command line program that generates Lapidary clients from OpenAPI.\n\n## Features\n\n- [x] Write Web API clients declaratively\n- [x] Use pydantic models for JSON data\n- [ ] Compatibility with OpenAPI 3.0 and 3.1\n\n## Installation\n\n```console\npip install lapidary\n```\n\nor with Poetry\n\n```console\npoetry add lapidary\n```\n\n## Usage\n\nWith Lapidary, you define an API client by creating a class that mirrors the API structure, akin to OpenAPI but through\ndecorated and annotated Python methods. Calling these method handles making HTTP requests and transforming the responses\nback into Python objects.\n\n```python\nfrom typing import Annotated, Self\nfrom lapidary.runtime import *\n\n# Define models\n\nclass Cat(ModelBase):\n    id: int\n    name: str\n\n# Declare the client\n\nclass CatClient(ClientBase):\n    def __init__(\n        self,\n        base_url='http://localhost:8080/api',\n    ):\n        super().__init__(base_url=base_url)\n\n    @get('/cat/{id}')\n    async def cat_get(\n        self: Self,\n        *,\n        id: Annotated[int, Path(style=ParamStyle.simple)],\n    ) -> Annotated[Cat, Responses({\n        '2XX': {\n            'application/json': Cat\n        },\n    })]:\n        pass\n\n# User code\n\nasync def main():\n    client = CatClient()\n    cat = await client.cat_get(id=7)\n```\n\nSee [this test file](https://github.com/python-lapidary/lapidary/blob/develop/tests/test_client.py) for a working\nexample.\n\n[Full documentation](https://lapidary.dev)\n\nAlso check the [library of clients](https://github.com/orgs/lapidary-library/repositories).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python async OpenAPI client library",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "https://github.com/python-lapidary/lapidary",
        "Repository": "https://github.com/python-lapidary/lapidary"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cafa12f05d9f63490950e72e1a0a9c2122a255ba8076e007ebc4ae4bfabc60c0",
                "md5": "2d46204d39c5e358a2857596035b7155",
                "sha256": "722a79fe3a2c44f7f04ff9fa05726d77e9aa81fafb23a3076fc701b109e5a143"
            },
            "downloads": -1,
            "filename": "lapidary-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d46204d39c5e358a2857596035b7155",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 15278,
            "upload_time": "2024-06-02T21:56:35",
            "upload_time_iso_8601": "2024-06-02T21:56:35.596141Z",
            "url": "https://files.pythonhosted.org/packages/ca/fa/12f05d9f63490950e72e1a0a9c2122a255ba8076e007ebc4ae4bfabc60c0/lapidary-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "978a19739814dcbc0f84b2bcc5475ecdc58cc136df6e3344d83cb882b5f9e4bf",
                "md5": "aa528c3e08c7fcb45fb84829ac598ec7",
                "sha256": "d73ea8b18b4109511e971257b9cb4adc467c22bd75c42eef39b6266e0c7f2f1c"
            },
            "downloads": -1,
            "filename": "lapidary-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "aa528c3e08c7fcb45fb84829ac598ec7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 11461,
            "upload_time": "2024-06-02T21:56:37",
            "upload_time_iso_8601": "2024-06-02T21:56:37.166161Z",
            "url": "https://files.pythonhosted.org/packages/97/8a/19739814dcbc0f84b2bcc5475ecdc58cc136df6e3344d83cb882b5f9e4bf/lapidary-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-02 21:56:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-lapidary",
    "github_project": "lapidary",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "lapidary"
}
        
Elapsed time: 0.36408s