You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Bash(curl -s -L --max-time 30 -A \"Mozilla/5.0 \\(Macintosh; Intel Mac OS X 10_15_7\\) AppleWebKit/537.36 \\(KHTML, like Gecko\\) Chrome/120.0.0.0 Safari/537.36\"\"https://developers.avito.ru/api-catalog\")",
41
+
"Bash(curl -s -L --max-time 30 -A \"Mozilla/5.0 \\(Macintosh; Intel Mac OS X 10_15_7\\) AppleWebKit/537.36 \\(KHTML, like Gecko\\) Chrome/120.0.0.0 Safari/537.36\"\"https://developers.avito.ru/dstatic/build/open-api-dev-portal.16ee9b7cf4f5ce68f019.js\")",
"Bash(curl -s -L --max-time 30 -A \"Mozilla/5.0 \\(Macintosh; Intel Mac OS X 10_15_7\\) AppleWebKit/537.36 \\(KHTML, like Gecko\\) Chrome/120.0.0.0 Safari/537.36\"\"https://developers.avito.ru/web/1/openapi/list\")",
44
+
"Bash(curl -s -L --max-time 30 -A \"Mozilla/5.0 \\(Macintosh; Intel Mac OS X 10_15_7\\) AppleWebKit/537.36 \\(KHTML, like Gecko\\) Chrome/120.0.0.0 Safari/537.36\"\"https://developers.avito.ru/web/1/openapi/info/messenger\")",
45
+
"Bash(curl -s -L --max-time 30 -A \"Mozilla/5.0 \\(Macintosh; Intel Mac OS X 10_15_7\\) AppleWebKit/537.36 \\(KHTML, like Gecko\\) Chrome/120.0.0.0 Safari/537.36\"\"https://developers.avito.ru/web/1/openapi/info/auth\")",
Copy file name to clipboardExpand all lines: CLAUDE.md
+42-8Lines changed: 42 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
8
8
make test# run all tests
9
9
make typecheck # mypy strict check on avito/
10
10
make lint # ruff check
11
+
make swagger-lint # strict Swagger binding coverage check
11
12
make fmt # ruff format
12
-
make check # test → typecheck → lint → build (full gate)
13
+
make check # test → typecheck → lint → swagger-lint → build (full gate)
13
14
make build # poetry build
14
15
15
16
# single test
@@ -41,18 +42,48 @@ poetry run pytest tests/test_facade.py::test_name
41
42
42
43
**Testing**: `tests/fake_transport.py` provides `FakeTransport` — inject it instead of real HTTP. Tests are Arrange/Act/Assert, one scenario per test. Test names describe behavior, not the method under test.
43
44
44
-
## API coverage and inventory
45
+
## API coverage
45
46
46
47
`docs/avito/api/` contains Swagger/OpenAPI specs (23 documents, 204 operations) — the authoritative source of truth for all API contracts.
48
+
The canonical SDK coverage map is built from Swagger operation bindings discovered on public domain methods, not from markdown inventory files.
47
49
48
-
`docs/avito/inventory.md` is the canonical mapping of every API operation to its SDK domain object and public method. Before implementing any new method, check the inventory to find:
49
-
- which `пакет_sdk` and `доменный_объект` it belongs to
50
-
- the expected `публичный_метод_sdk`, request/response type names
51
-
- whether the operation is deprecated (`deprecated: да` → wrap in a legacy domain object)
50
+
Public SDK methods are documented in `docs/site/reference/` and generated by the MkDocs reference builder from the actual package surface. All 204 operations from the specs must be covered. A missing method is a defect.
52
51
53
-
**When adding a new API method**: add it to the `## Операции` table in `docs/avito/inventory.md` (between the `operations-table:start/end` markers) following the existing format.
52
+
## Swagger binding subsystem
54
53
55
-
All 204 operations from the specs must be covered. A missing method is a defect.
54
+
The persistent subsystem context is documented in `docs/site/explanations/swagger-binding-subsystem.md`.
55
+
56
+
Core invariant:
57
+
58
+
```text
59
+
each Swagger operation -> exactly one discovered binding
60
+
each discovered SDK method -> exactly one Swagger operation
61
+
```
62
+
63
+
Multiple Swagger bindings on one public SDK method are forbidden. If one public scenario covers different upstream modes, expose separate documented SDK methods and keep compatibility wrappers unbound.
64
+
65
+
When adding or changing a public method that corresponds to Avito API:
66
+
67
+
- consult `docs/avito/api/*.json` first;
68
+
- add or update the public domain method, section client call, mapper and typed public models;
69
+
- add `@swagger_operation(...)` on the public domain method;
70
+
- do not put schemas, statuses, content types, request models, response models, error models, path params, or query params into the decorator;
71
+
- add or update class-level Swagger metadata when introducing a domain class;
72
+
- write a reference-ready docstring for the public method: business action, arguments, return model, pagination/dry-run/idempotency behavior when relevant, and common SDK exceptions;
73
+
- update `docs/site/how-to/` or `docs/site/explanations/` if the method introduces a workflow or a non-obvious contract;
74
+
- update `docs/site/explanations/swagger-binding-subsystem.md` when changing discovery, linter, JSON report, `SwaggerFakeTransport`, deprecated/legacy policy, or multi-operation binding policy.
75
+
76
+
Minimum verification for API-related changes:
77
+
78
+
```bash
79
+
make swagger-lint
80
+
poetry run pytest tests/core/test_swagger*.py tests/contracts/test_swagger_contracts.py
81
+
poetry run pytest tests/domains/<domain>/
82
+
poetry run mypy avito
83
+
poetry run ruff check .
84
+
```
85
+
86
+
Before completing an API-surface change, run `make check`. If generated docs, docs snippets, coverage pages, or reference output changed, also run `make docs-strict`.
56
87
57
88
## STYLEGUIDE.md — strict compliance is mandatory
58
89
@@ -64,6 +95,9 @@ The most critical prohibitions that must never be violated:
64
95
- Returning `dict` or `Any` from public methods.
65
96
- Using `resource_id` instead of concrete names (`item_id`, `order_id`).
66
97
- Annotating `list[T]` where `PaginatedList[T]` is returned at runtime.
98
+
- Adding or changing an Avito API public method without a `@swagger_operation(...)` binding.
99
+
- Adding or changing an Avito API public method without a reference-ready docstring.
100
+
- Duplicating Swagger contract data inside binding decorators.
67
101
- Making `AuthenticationError` a subclass of `AuthorizationError` (or vice versa).
68
102
- Writing error messages in mixed languages (Russian only).
69
103
- Injecting methods via `setattr`/`globals()` at runtime.
SDK является синхронным. Любая асинхронная поддержка, если она появится, будет жить в отдельном namespace `avito.aio` и никогда не будет смешана с sync-классами в одном модуле.
14
+
```python
15
+
from avito import AvitoClient
19
16
20
-
Каталог [docs/avito/api](docs/avito/api) рассматривается как upstream API contract. Эти файлы не редактируются вручную при развитии SDK: публичные модели, мапперы и тесты должны подстраиваться под documented shape из `docs/avito/api/*`.
17
+
with AvitoClient.from_env() as avito:
18
+
profile = avito.account().get_self()
19
+
ad = avito.ad(item_id=42, user_id=123).get()
20
+
21
+
print(profile.name)
22
+
print(ad.title)
23
+
```
24
+
25
+
По умолчанию настройки читаются из переменных окружения с префиксом `AVITO_`.
26
+
27
+
`avito-py` — синхронный Python SDK для работы с Avito API через единый объектный фасад `AvitoClient`.
21
28
22
29
## Установка
23
30
@@ -33,23 +40,6 @@ pip install avito-py
33
40
34
41
Требование к интерпретатору: Python `3.14` и выше в рамках ветки `3.x`. Репозиторий и релизный контур валидируются именно на Python `3.14`.
0 commit comments