← 返回列表
全部 Skill›开发 Development›frontend-openapi-mapper

frontend-openapi-mapper

作者 @findsun-vn · 语言 en
Convert OpenAPI contracts into strongly typed Vue frontend modules with auth-aware flows and Ant Design Vue UI conventions.
开发 Development前端开发通用访问网络待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
0
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Skill: frontend-openapi-mapper

Purpose

Convert OpenAPI contracts into frontend code that is:

  • strongly typed
  • module-based
  • consistent with the single Vue application structure
  • safe for stores, pages, composables, and route integration
  • aligned with Ant Design Vue UI conventions
  • capable of handling authentication and authorization module flows cleanly

Frontend Architecture Assumption

This project uses:

  • one Vue application
  • Vue 3
  • Composition API
  • TypeScript
  • Axios
  • Pinia
  • Vue Router
  • Ant Design Vue

Business modules live under:

frontend/src/modules/<module_name>/

Standard module structure:

  • api/
  • components/
  • composables/
  • pages/
  • stores/
  • types/
  • routes.ts

Shared generic code belongs under:

  • frontend/src/shared/api/
  • frontend/src/shared/components/
  • frontend/src/shared/composables/
  • frontend/src/shared/utils/
  • frontend/src/shared/types/

Global app concerns belong under:

  • frontend/src/router/
  • frontend/src/stores/
  • frontend/src/layouts/

API Mapping Rule

Each OpenAPI endpoint should map into:

  • a typed function in the module API layer
  • the correct request/response types
  • store usage where appropriate
  • pages/composables that consume it safely

Do not:

  • hardcode endpoints outside the API layer
  • bypass typed API abstractions
  • duplicate endpoint logic across multiple files unnecessarily

Response Envelope Rule

All successful responses use the standard envelope:

type ApiResponse<T> = {

code: number

message: string

data: T

}

Frontend code must understand that:

  • business payload lives inside data
  • stores/composables/pages must not treat payload as top-level raw data

Pagination Mapping Rule

Paginated endpoint payloads use:

type PageResponse<T> = {
  content: T[]
  page: number
  size: number
  total: number
}

Combined contract:

type ApiPageResponse<T> = ApiResponse<PageResponse<T>>

Stores and composables must read pagination fields from:

  • response.data

not from a fake raw top-level object.


Type Generation Rule

Generate strict types from OpenAPI schemas.

Typical OpenAPI-aligned naming:

  • CreateXRequest
  • UpdateXRequest
  • XResponse

Frontend naming should stay aligned with OpenAPI when practical.

Keep module-local types in:

frontend/src/modules/<module_name>/types/

Keep only generic reusable types in:

frontend/src/shared/types/

Good shared generic types:

  • ApiResponse<T>
  • PageResponse<T>
  • SelectOption
  • TableQuery
  • RouteMetaPermission

Avoid moving business-specific module types into shared.


Store Mapping Rule

Module stores must:

  • live under module stores/
  • call module api/
  • handle loading state
  • handle error state
  • unwrap response envelopes correctly
  • keep module business state centralized

Forbidden:

  • calling axios directly from store when module API layer exists
  • scattering the same business state across many files
  • assuming API payload is already top-level

Global app stores belong only in:

frontend/src/stores/

Use global stores only for truly app-wide concerns.


Composable Mapping Rule

Use module composables for:

  • page-level reusable logic
  • search/filter/sort state
  • form logic
  • table state
  • modal/drawer state
  • pagination helpers specific to the module
  • auth-related reusable UI logic when the module is auth

Use shared composables only for truly generic concerns:

  • useLoading
  • usePagination
  • useDebounce
  • useAsyncState

Do not move business-specific logic into shared prematurely.


Route Mapping Rule

Each module should expose routes through:

frontend/src/modules/<module_name>/routes.ts

Admin/storefront distinction should be expressed through:

  • route meta
  • route guards
  • layout usage

Not through separate frontend apps.

Route guards belong under:

frontend/src/router/guards/


UI Library Assumption

This project uses Ant Design Vue as the primary UI component library.

When mapping OpenAPI contracts into pages and components:

  • prefer Ant Design Vue for standard CRUD and business UI
  • prefer Ant Design Vue Table for list pages
  • prefer Ant Design Vue Form for create/edit flows
  • prefer Ant Design Vue Modal/Drawer for overlays when appropriate
  • prefer Ant Design Vue feedback patterns for loading, empty, error, and success states

Do not introduce another main UI library unless explicitly requested.


Ant Design Vue UI Mapping Rule

Use Ant Design Vue by default for:

  • Button
  • Form
  • Form.Item
  • Input
  • Input.Password
  • Input.Search
  • Select
  • Radio
  • Checkbox
  • Switch
  • DatePicker
  • InputNumber
  • Table
  • Tag
  • Card
  • Tabs
  • Modal
  • Drawer
  • Pagination
  • Alert
  • Result
  • Empty
  • Spin
  • message
  • notification

Avoid building raw custom UI for standard enterprise patterns when Ant Design Vue already provides a suitable component.


List Page Mapping Rule

For list pages, prefer:

  • a-card or a clean page wrapper
  • search/filter toolbar with Ant Design Vue controls
  • a-table for tabular business data
  • a-pagination where needed
  • a-tag for status rendering
  • a-button for primary/secondary actions

List page mapping should stay aligned with:

  • API filters
  • sort behavior
  • pagination contract
  • status enum display

Form Page Mapping Rule

For create/edit forms, prefer:

  • a-form
  • a-form-item
  • a-input
  • a-input-password
  • a-select
  • a-switch
  • a-checkbox
  • a-radio-group
  • a-date-picker
  • a-input-number
  • a-upload when applicable

Validation should align with:

  • OpenAPI-required fields
  • backend validation rules
  • reasonable UX expectations

Do not overbuild custom form systems when Ant Design Vue already covers the use case.


Detail / Overlay Mapping Rule

For detail pane

评论
Ffindsun-vn
findsun-vn
findsun-vn/E-Commerce
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@findsun-vn
所属大类开发 Development / 前端开发
国内可用性通用
最近源活动—
风险提示访问网络
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。