Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计未展示

manage-server-data%2fgenerate-rtk-query-from-openapi管理服务器数据%2f 从 openapi 生成 rtk 查询

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

333

周安装

14

GitHub Stars

11,199

下载量

116
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:manage-server-data%2fgenerate-rtk-query-from-openapi(管理服务器数据%2f 从 openapi 生成 rtk 查询)
来源仓库:https://github.com/reduxjs/redux-toolkit
仓库路径:skills/manage-server-data%2Fgenerate-rtk-query-from-openapi
安装命令:
npx skills add https://github.com/reduxjs/redux-toolkit --skill manage-server-data/generate-rtk-query-from-openapi
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/reduxjs/redux-toolkit --skill manage-server-data/generate-rtk-query-from-openapi

简介

用于辅助 API 接口和 OpenAPI 文档生成。

  • 适合从接口定义生成 RTK Query 代码。
  • 需确认业务语义和错误处理规则。manage-server-data%2fgenerate-rtk-query-from-openapi 属于开发类 Skill,可作为该场景下的辅助能力补充。
  • 避免凭空补字段,应基于真实接口样例。
  • 建议参考原始文档了解支持的 API 格式。

SKILL.md

Generate RTK Query From OpenAPI

Setup

// file: src/store/emptyApi.ts
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const emptySplitApi = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
  endpoints: () => ({}),
})

// file: openapi-config.ts
import type { ConfigFile } from '@rtk-query/codegen-openapi'

const config: ConfigFile = {
  schemaFile: 'https://petstore3.swagger.io/api/v3/openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
  hooks: true,
}

export default config

Run:

npx @rtk-query/codegen-openapi openapi-config.ts

Core Patterns

Generate into an empty shared API

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const emptySplitApi = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
  endpoints: () => ({}),
})

Codegen works best when it extends a single RTK Query architecture instead of creating standalone API roots.

Filter endpoints when the schema is too broad

import type { ConfigFile } from '@rtk-query/codegen-openapi'

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/userApi.ts',
  exportName: 'userApi',
  hooks: true,
  filterEndpoints: ['loginUser', /User/],
}

export default config

Start with a narrow slice of the schema if the full surface area is too noisy or the package boundaries differ from the OpenAPI file.

Use endpointOverrides to fix generation results

import type { ConfigFile } from '@rtk-query/codegen-openapi'

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
  hooks: true,
  tag: true,
  endpointOverrides: [
    {
      pattern: 'loginUser',
      type: 'mutation',
    },
    {
      pattern: /.*/,
      parameterFilter: (_name, parameter) => parameter.in !== 'header',
    },
    {
      pattern: 'getPetById',
      providesTags: ['SinglePet'],
    },
  ],
}

export default config

Review generated endpoints and override type, parameter, or tag behavior instead of hand-editing the emitted file.

Common Mistakes

HIGH Assuming generated tags are already specific enough

Wrong:

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
  tag: true,
}

Correct:

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
  tag: true,
  endpointOverrides: [
    {
      pattern: 'getPetById',
      providesTags: ['SinglePet'],
    },
  ],
}

Generated tags are string-only by default, so they can invalidate more cache than intended.

Source: reduxjs/redux-toolkit:docs/rtk-query/usage/code-generation.mdx

HIGH Generating a brand-new API root instead of extending an empty one

Wrong:

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

type Pet = { id: string; name: string }

export const petApi = createApi({
  reducerPath: 'petApi',
  baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
  endpoints: (build) => ({
    getPetById: build.query<Pet, string>({
      query: (id) => `pets/${id}`,
    }),
  }),
})

Correct:

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const emptySplitApi = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
  endpoints: () => ({}),
})

Generated code should plug into one RTK Query architecture so invalidation and store wiring stay coherent.

Source: reduxjs/redux-toolkit:docs/rtk-query/usage/code-generation.mdx

MEDIUM Trusting generated shapes without overrides or review

Wrong:

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
}

Correct:

const config: ConfigFile = {
  schemaFile: './openapi.json',
  apiFile: './src/store/emptyApi.ts',
  apiImport: 'emptySplitApi',
  outputFile: './src/store/petApi.ts',
  exportName: 'petApi',
  endpointOverrides: [
    {
      pattern: 'loginUser',
      type: 'mutation',
    },
  ],
}

Real schemas often need type, parameter, or tag correction; treat generated output as reviewed source, not gospel.

Source: reduxjs/redux-toolkit:docs/rtk-query/usage/code-generation.mdx

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.98%
按下载量换算42

Claude

31.59%
按下载量换算37

Cursor

16.23%
按下载量换算19

Gemini CLI

9.26%
按下载量换算11

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills