Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

api-endpoints

/api-endpoints

Prowadzi przez dodanie lub zmianę endpointu DRF: serializer, widok, rejestrację URL, klienta OpenAPI i typy po stronie frontendu.

Repozytorium
overmind ↗
Licencja
AGPL-3.0
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.

Co robi i kiedy

Prowadzi przez dodanie lub zmianę endpointu DRF: serializer, widok, rejestrację URL, klienta OpenAPI i typy po stronie frontendu.

Oryginalny opis (EN)

End-to-end workflow for adding or changing a backend API endpoint — which module the serializer and view belong in, URL registration, OpenAPI client regeneration, and typed consumption from the frontend. Use when adding, changing, or removing a DRF endpoint or serializer.

Jak działa

  1. 1. Serializer and view go in the surface's own module
  2. 2. Register the route
  3. 3. Regenerate the client
  4. 4. Register the API class in client.ts
  5. 5. Consume through the client, never raw fetch
  6. Rules
Sekcje z nagłówków SKILL.md, w oryginale · 64 linii, 402 słów
Podgląd SKILL.md
---
name: api-endpoints
description: End-to-end workflow for adding or changing a backend API endpoint — which module the serializer and view belong in, URL registration, OpenAPI client regeneration, and typed consumption from the frontend. Use when adding, changing, or removing a DRF endpoint or serializer.
---

# Adding or changing an API endpoint

The frontend consumes the backend exclusively through the generated typescript-fetch client at `frontend/src/openapi/`. Every API change runs the full loop below.

## 1. Serializer and view go in the surface's own module

`overbae/api/` is one module per surface — `eval_views.py`/`eval_serializers.py`, `datasets.py`/`dataset_serializers.py`, `optimizer.py`, `billing.py`, `otlp.py`, and so on. `views.py` and `serializers.py` are the legacy monoliths; a new surface gets its own module rather than growing them.

Never return a raw dict from a view — request and response shapes are serializers. Keep business logic in `services/` or on the model; annotate with `@extend_schema` where drf-spectacular needs help.

Expected input failures may use `core.errors.InputValidationError` with an authored public `detail`. Never build that detail from a caught exception, provider response or stored diagnostic. Return the authored detail for known failures; log unexpected exceptions server-side and return a fixed message. Apply the same boundary to MCP adapters.

## 2. Register the route

`overbae/urls.py`, on the `DefaultRouter` for viewsets:

```python
router.register(r"widgets", WidgetViewSet, basename="widget")
```

or in `urlpatterns` for plain views.

## 3. Regenerate the client

```bash
make generate_api_client
```

Settings refuse to load without Modal tokens when `.env` has none: prefix with `MODAL_TOKEN_ID=dummy MODAL_TOKEN_SECRET=dummy` — the schema step never talks to Modal.

Runs `manage.py spectacular` → dockerized `openapi-generator-cli` → rewrites `frontend/src/openapi/{apis,models}`.

The Compose frontend uses polling because Docker bind mounts can miss files recreated by generation. A method present on disk but missing at runtime can be a stale Vite transform: check the JavaScript served at `/src/openapi/apis/<Api>.ts`. Recreate the frontend with `docker compose up -d --no-deps frontend` after changing its watcher environment; restarting alone does not apply environment changes.

## 4. Register the API class in `client.ts`

```typescript
import { WidgetsApi } from "./openapi";

export class API {
  widgets: WidgetsApi;
  constructor(private cfg: Configuration) {
    this.widgets = new WidgetsApi(this.cfg);
  }
}
```

## 5. Consume through the client, never raw fetch

```typescript
import api from "@/client";
import type { Widget } from "@/openapi";

const widget: Widget = await api.widgets.widgetsRetrieve({ id });
```

Hardcoded URLs and bare `fetch`/`axios` bypass auth middleware and typing. Response types come from `frontend/src/openapi/models/` — never redeclare a type that already exists there.

## Rules

- Never hand-edit anything under `frontend/src/openapi/` — a hook blocks it under Claude Code, and the next regeneration would overwrite it anyway.
- A DRF view docstring becomes the OpenAPI operation `description`, so editing one changes the generated client. Prefer an explicit `@extend_schema(summary=...)`.

Wersje

W bazie nie ma innych skilli o nazwie api-endpoints.

Migawka bazy z 28.10.2026 · wersja paczki 3aa9ea85f913 (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100django-rest-framework-patterns
    Prowadzi przez Django REST Framework: ViewSety i routery, granice serializerów, przepływ żądania, naprawę N+1 w get_queryset, drf-spectacular, django-filter, SimpleJWT i paginację.
  • 98improving-drf-endpoints
    Przegląda i poprawia widoki oraz serializery DRF w PostHog: typowanie pól, adnotacje schematu, kolizje enumów i jakość specyfikacji OpenAPI dla generowanych typów TypeScript i narzędzi MCP.
  • 100design-http-api
    Ustala kontrakt OpenAPI 3.1 dla endpointów HTTP: błędy RFC 9457, paginację kursorową, klucze idempotentności, wersjonowanie i wygenerowanego typowanego klienta za warstwą fetchera frontendu.
  • 100document-api-endpoint
    Uzgadnia wygenerowany schemat OpenAPI i zadeklarowane typy odpowiedzi endpointu API z jego faktyczną odpowiedzią w czasie działania.
  • 100archestra-dev-backend
    Pomaga dodawać i zmieniać backend Archestra: trasy, modele, serwisy, schematy żądań i odpowiedzi API, uprawnienia endpointów oraz OpenAPI i generowanie klienta API.
  • 95rails-cto-api
    Podpowiada, jak budować API JSON w Rails 8 zgodnie z OpenAPI: kontrolery, serializatory, uwierzytelnianie i paginację.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.