Skip to main content

transformers-generator

Design of the ejected Redocly `transformers` client generator. Read it, and update it, before changing generators/transformers/.

ソース情報

リポジトリ
Redocly/redocly-cli
ソースの最終更新活動
2026年10月26日 07:46
検出された SKILL.md の言語
英語
スター
1,543
フォーク
235

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。

SKILL.md を表示中

SKILL.md
ソースの指示 · 読み取り専用プレビュー
name
transformers-generator
description
Design of the ejected Redocly `transformers` client generator. Read it, and update it, before changing generators/transformers/.
# The `transformers` generator — its skill This file is the DESIGN of your ejected `transformers` generator (`generators/transformers/`): **to change the generator, edit this skill first, then make the code match it** — a diff to `generators/transformers/` that has no covering sentence here is incomplete. ## What it emits Per-schema `to<Name>()` / `from<Name>()` converters that turn wire JSON into typed values and back — the bridge for `dateType: Date` clients. ## Design decisions that must hold - **Requires `dateType: Date`** (declared as `dateTypes: ['Date']`, so a mismatched selection fails fast): the converters assign `Date` objects to fields the sdk types as `Date`, which only type-checks in that mode. - **Imports the sdk's schema TYPES** (so `typescript` is required) and nothing else. - Converters are pure and total: every named schema gets a pair, nested structures recurse, and a missing optional stays missing. - **A transform takes response data.** A response never carries `writeOnly` properties, so the sdk types it `Omit<Name, …>`. The transform of a schema with `writeOnly` properties takes that shape and returns the type it was given: `<T extends Omit<Name, …>>(input: T): T`. Other transforms keep `(data: Name): Name`. ## The stage files `render.ts` holds the whole converter renderer; `index.ts` is the entry. Naming comes from the TypeScript printer (`@redocly/client-generator/printers/typescript`). ## Ejecting it `redocly eject-generator transformers` copies this generator's TypeScript source folder to `generators/transformers/`, exactly as we wrote it, importing `@redocly/client-generator` and `@redocly/client-generator/printers/typescript`. Running a `.ts` generator uses Node's type stripping (Node 22.18, 23.6, or newer); newer built-in versions merge in per file with `--update`. Change which fields are converted, or how, and regenerate. ## The modify loop 1. Edit this skill: state the new behavior or decision. 2. Make `generators/transformers/` match it. 3. Run `redocly generate-client` and inspect the `git diff` of the generated output — generated files are never hand-edited. Newer built-in versions merge in with `redocly eject-generator transformers --update`.
GitHubで見る