document-api-endpoint

작성자: sentry

Sentry API 엔드포인트를 문서화하고 타입을 지정합니다. @extend_schema 데코레이터를 작성하거나 수정하고, 응답 TypedDict를 지정하며, 요청 파라미터의 타입을 지정하고, 타입 드리프트를 수정합니다…

npx skills add https://github.com/getsentry/skills --skill document-api-endpoint

Document & Type a Sentry API Endpoint

Add or fix OpenAPI docs for a Sentry endpoint with drf-spectacular. Full reference is at https://develop.sentry.dev/backend/api/public/, the most useful section to you will be https://develop.sentry.dev/backend/api/public/#5-method-decorator. This skill captures the non-obvious lessons on top of it. Most of the work is making the declared schema match what the endpoint actually returns. Before documenting, identify which endpoint class serves the route and what it does; the MCP tool that calls it is usually the fastest way to confirm its behavior. Promoting a PRIVATE/EXPERIMENTAL endpoint to PUBLIC is one application (see below).

Workflow

  1. Class-level @extend_schema(tags=[...]) — use the closest existing OPENAPI_TAGS entry.
  2. Method-level @extend_schema(operation_id=..., parameters=[...], responses={...}, examples=...).
  3. Reuse src/sentry/apidocs/parameters.py and examples/*.py; ensure owner = ApiOwner.<TEAM> is set.
  4. If a legacy api-docs/paths/**/*.json covers the path, remove it (see lesson 4).
  5. Validate, then verify against the live endpoint (lesson 1).

Lessons

1. Carefully compare what the code does vs declared types

Ideally, hit the live endpoint with a real token and diff the keys and types against your TypedDict. Serializers are sometimes inaccurate. Look out for counts coming back as floats instead of integers, IDs declared int emitted as strings, nested types declaring the wrong number of fields. Correct the declared type to match runtime.

curl -s -H "Authorization: Bearer $TOKEN" "https://us.sentry.io/api/0/<endpoint>" | jq 'keys'

2. Reuse the canonical response type

Match the codebase's XxxResponseOptional(TypedDict, total=False) mixin (main class declares required fields). Nullable-vs-absent: T | None = key always present, value may be null; NotRequired[T] = key only set under a condition (e.g. an expand query param). Reuse the existing canonical type instead of re-declaring a second or third copy in a *_types.py. If there's no clean canonical type to reuse (e.g. a payload proxied from another service like vroom/profiling), type it dict[str, Any] rather than inventing a new mirror, and confirm the shape from the owning service's repo, not just the serializer.

3. Infer the type. Avoid cast and # type: ignore

When a serializer returns a base type plus extra fields, refactor the producing code so the response type is inferred rather than forced.

4. Legacy doc migration is all-or-nothing per path

Delete the api-docs/paths/**/*.json file AND its $ref in api-docs/openapi.json. drf-spectacular's APPEND_PATHS does not merge HTTP methods, so once any method on a path uses @extend_schema, all legacy methods on that path vanish — migrate every method on the path in one commit.

Promoting to PUBLIC

Do the workflow above, then on the concrete endpoint only (leave siblings PRIVATE):

  • Bump publish_status[<METHOD>]PUBLIC and set owner = ApiOwner.<TEAM>.
  • Remove the method from API_OWNERSHIP_ALLOWLIST_DONT_MODIFY in the same change as the flip.
  • If the endpoint is redundant or being renamed, delete or deprecate the old version in its own change first, then stack the publish on top.
  • Note in the PR if scopes widen (event:readevent:{admin,read,write}) — that's drf-spectacular regenerating from permission_classes, documentation-only.

The change reaches the @sentry/api SDK / MCP only after sentry-api-schema regenerates downstream.

Validate

make build-api-docs
pnpm run validate-api-examples
.venv/bin/pytest -q --reuse-db tests/apidocs/endpoints/<area>/test_<name>.py
.venv/bin/prek run -q --files <changed paths>

sentry의 다른 스킬

generate-frontend-forms
sentry
Sentry의 새로운 폼 시스템을 사용하여 폼을 생성하는 가이드입니다. 폼, 폼 필드, 유효성 검사 또는 자동 저장 기능을 구현할 때 사용하세요.
official
sentry-snapshots-cocoa
sentry
Apple/Cocoa 프로젝트를 위한 전체 Sentry Snapshots 설정입니다. "SnapshotPreviews 설정", "Apple 스냅샷 테스트 설정", "Apple 스냅샷 업로드" 요청 시 사용하세요.
official
architecture-review
sentry
직원 수준의 코드베이스 건강 검토. 모놀리식 모듈, 무음 실패, 타입 안전성 격차, 테스트 커버리지 구멍, LLM 친화성 문제를 찾습니다.
official
linear-type-labeler
sentry
Linear 이슈를 분류하고, 각 이슈의 제목과 설명 내용을 기반으로 Sentry 워크스페이스의 레이블 분류 체계에서 Type 레이블을 적용합니다.
official
sentry-flutter-sdk
sentry
Flutter 및 Dart를 위한 완전한 Sentry SDK 설정입니다. "Flutter에 Sentry 추가", "sentry_flutter 설치", "Dart에서 Sentry 설정" 또는 오류 구성을 요청받았을 때 사용하세요.
official
sentry-svelte-sdk
sentry
Svelte 및 SvelteKit을 위한 완전한 Sentry SDK 설정입니다. "Svelte에 Sentry 추가", "SvelteKit에 Sentry 추가", "@sentry/sveltekit 설치" 또는 구성 요청 시 사용하세요.
official
vercel-react-best-practices
sentry
Vercel Engineering의 React 및 Next.js 성능 최적화 가이드라인입니다. 이 스킬은 React/Next.js 코드를 작성, 검토 또는 리팩토링할 때 사용해야 합니다.
official
sentry-tanstack-start-sdk
sentry
TanStack Start React용 전체 Sentry SDK 설정. "TanStack Start에 Sentry 추가", "@sentry/tanstackstart-react 설치" 또는 오류 구성 요청 시 사용…
official