TopRank Skills

Home / Claw Skills / Analyse des données / phoenix-api-gen
Official OpenClaw rules 54%

phoenix-api-gen

Generate a full Phoenix JSON API from an OpenAPI spec or natural language description. Creates contexts, Ecto schemas, migrations, controllers, JSON views/renderers, router entries, ExUnit tests with factories, auth plugs, and tenant scoping. Use when building a new Phoenix REST API, adding CRUD endpoints, scaffolding resources, or converting an OpenAPI YAML into a Phoenix project.

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 phoenix-api-gen 技能。 若已安装,则直接安装 phoenix-api-gen 技能。

Overview

Skill Key
gchapim/phoenix-api-gen
Author
gchapim
Source Repo
openclaw/skills
Version
-
Source Path
skills/gchapim/phoenix-api-gen
Latest Commit SHA
1f3f223ac3e350bb9561304010f8a06cce4351be

Extracted Content

SKILL.md excerpt

# Phoenix API Generator

## Workflow

### From OpenAPI YAML

1. Parse the OpenAPI spec — extract paths, schemas, request/response bodies.
2. Map each schema to an Ecto schema + migration.
3. Map each path to a controller action; group by resource context.
4. Generate auth plugs from `securitySchemes`.
5. Generate ExUnit tests covering happy path + validation errors.

### From Natural Language

1. Extract resources, fields, types, and relationships from the description.
2. Infer context boundaries (group related resources).
3. Generate schemas, migrations, controllers, views, router, and tests.
4. Ask the user to confirm before writing files.

## File Generation Order

1. Migrations (timestamps prefix: `YYYYMMDDHHMMSS`)
2. Ecto schemas + changesets
3. Context modules (CRUD functions)
4. Controllers + FallbackController
5. JSON renderers (Phoenix 1.7+ `*JSON` modules, or `*View` for older)
6. Router scope + pipelines
7. Auth plugs
8. Tests + factories

## Phoenix Conventions

See [references/phoenix-conventions.md](references/phoenix-conventions.md) for project structure, naming, context patterns.

Key rules:
- One context per bounded domain (e.g., `Accounts`, `Billing`, `Notifications`).
- Context is the public API — controllers never call Repo directly.
- Schemas live under contexts: `MyApp.Accounts.User`.
- Controllers delegate to contexts; return `{:ok, resource}` or `{:error, changeset}`.
- Use `FallbackController` with `action_fallback/1` to handle error tuples.

## Ecto Patterns

See [references/ecto-patterns.md](references/ecto-patterns.md) for schema, changeset, migration details.

Key rules:
- Always use `timestamps(type: :utc_datetime_usec)`.
- Binary IDs: `@primary_key {:id, :binary_id, autogenerate: true}` + `@foreign_key_type :binary_id`.
- Separate `create_changeset/2` and `update_changeset/2` when create/update fields differ.
- Validate required fields, formats, and constraints in changesets — not in controllers.

## Multi-Tenancy

Add `tenant_id :bina...

Related Claw Skills