Skip to content

Commit 6564e19

Browse files
🔥 Remove duplicated docs on installation; improve docs.
1 parent 99dce30 commit 6564e19

File tree

5 files changed

+26
-71
lines changed

5 files changed

+26
-71
lines changed

‎.config/mkdocs.yaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ exclude_docs: |
1717
nav:
1818
- index.md
1919
- Usage:
20-
- Installation: usage/installation.md
21-
- usage/client.md
20+
- Client class: usage/client.md
2221
- usage/operation.md
2322
- usage/auth.md
2423
- API reference: reference/api.md

‎Readme.md‎

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,20 @@
22

33
[![test](https://github.com/python-lapidary/lapidary/actions/workflows/test_publish.yaml/badge.svg)](https://github.com/python-lapidary/lapidary/actions/workflows/test_publish.yaml)
44

5-
Python DSL for Web API clients.
5+
Python Helper for Web API clients.
66

77
## Why
88

9-
Web API clients follow a relatively small set of patterns and implementing them is rather repetitive task. Encapsulating these patterns in form of a DSL library frees its users from coding the same patterns over and over again.
9+
Web API clients follow a relatively small set of patterns and implementing them is rather repetitive task.
10+
Prepare request, make the call, handle response status, deserialize the body
11+
Typical examples show how to use `request.get()` or similar method, but this is an anti-pattern. These calls should be encapsulated as module functions or methods.
1012

1113
## How
1214

13-
Lapidary is an internal (in-python) DSL made of decorators and annotations, that can be used to describe Web APIs similarly to OpenAPI.
14-
([lapidary-render](https://github.com/python-lapidary/lapidary-render/) can convert a large subset of OpenAPI 3.0 to Lapidary).
15-
16-
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`.
17-
18-
### Example:
19-
20-
```python
21-
class CatClient(ClientBase):
22-
"""This class is a working API client"""
23-
24-
def __init__(self):
25-
super().__init__(
26-
base_url='https://example.com/api',
27-
)
28-
29-
@get('/cat')
30-
async def list_cats(self: Self) -> Annotated[
31-
tuple[list[Cat], CatListMeta],
32-
Responses({
33-
'2XX': Response(
34-
Body({
35-
'application/json': list[Cat],
36-
}),
37-
CatListMeta
38-
),
39-
})
40-
]:
41-
pass
42-
43-
client = CatClient()
44-
cats_body, cats_meta = await client.list_cats()
45-
```
15+
Lapidary is a library that provides decorators and annotations for describing Web APIs in a way similar to OpenAPI.
16+
In fact [lapidary render](https://github.com/python-lapidary/lapidary-render/) can convert much of OpenAPI 3.0 to Lapidary code.
17+
18+
At runtime, the library interprets user-provided function declarations and makes them behave as specified.
19+
If a function accepts parameter of type `X` and returns `Y`, Lapidary will try to convert `X` to HTTP request and the response back to `Y`.
20+
21+
Check the [example](https://python-lapidary.github.io/lapidary/#usage)

‎docs/index.md‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Lapidary
22

3-
Python DSL for Web API clients.
3+
Python helper for creating Web API clients.
44

55
## Features
66

77
- [x] Write Web API clients declaratively
8-
- [x] Use pydantic models for JSON data
9-
- [ ] Compatibility with OpenAPI 3.0 and 3.1
8+
- [x] Use [pydantic](https://docs.pydantic.dev/latest/) models for JSON data
9+
- [x] Compatibility with [OpenAPI](https://www.openapis.org/)
10+
- [x] 3.0
11+
- [ ] 3.1 (Planned)
1012

1113
## Installation
1214

@@ -57,9 +59,10 @@ class CatClient(ClientBase):
5759
})),
5860
})]:
5961
pass
62+
```
6063

61-
# User code
62-
64+
User code
65+
```python
6366
async def main():
6467
client = CatClient()
6568
cat = await client.cat_get(id=7)
@@ -68,6 +71,9 @@ async def main():
6871
See [this test file](https://github.com/python-lapidary/lapidary/blob/develop/tests/test_client.py) for a working
6972
example.
7073

71-
[Full documentation](https://lapidary.dev)
74+
Also check [clients](https://github.com/orgs/lapidary-library/repositories) generated with Lapidary Render.
75+
76+
77+
## Prior work
7278

73-
Also check the [library of clients](https://github.com/orgs/lapidary-library/repositories).
79+
[Uplink 📡](https://uplink.prkumar.dev/) - more mature and full-featured but not designed with OpenAPI compatibility in mind.

‎docs/usage/installation.md‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎docs/usage/operation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CatClient(ClientBase):
2222

2323
!!! note
2424

25-
In the examples below, methods are depicted as standalone functions, with the encapsulating class structure omitted.
25+
In the examples below, methods are written as top-level functions, while in real code you would write them as methods.
2626

2727
```python
2828
@get('/cats') # method and path

0 commit comments

Comments
 (0)