frontend-openapi-mapper
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:
CreateXRequestUpdateXRequestXResponse
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>SelectOptionTableQueryRouteMetaPermission
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:
useLoadingusePaginationuseDebounceuseAsyncState
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-cardor a clean page wrapper- search/filter toolbar with Ant Design Vue controls
a-tablefor tabular business dataa-paginationwhere neededa-tagfor status renderinga-buttonfor 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-forma-form-itema-inputa-input-passworda-selecta-switcha-checkboxa-radio-groupa-date-pickera-input-numbera-uploadwhen 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
