Support loading a config from a `openapi-codegen.config.mts` file
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- cli
調査の方向性
Reproduce the failure with npx openapi-codegen -c openapi-codegen.config.mts using the configuration shown in the issue. Start at GenerateCommand.getFromOptions around lib/cli.js:282 and trace how the .mts export is loaded. Done means the module-style config loads without the workaround and generation proceeds successfully.
索引モデルが issue の本文から書いたものです。
説明
When i use the mts file extension to define my config as a module, rather than allowing it to be treated as commonjs, the loading doesnt work properly. With npx openapi-codegen -c openapi-codegen.config.mts, i see
Type Error: Cannot read properties of undefined (reading 'source')
at GenerateCommand.getFromOptions (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/@openapi-codegen/cli/lib/cli.js:282:47)
at Object.task (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/@openapi-codegen/cli/lib/cli.js:364:32)
at xe (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/@clack/prompts/dist/index.mjs:79:394)
at GenerateCommand.execute (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/@openapi-codegen/cli/lib/cli.js:359:11)
at async GenerateCommand.validateAndExecute (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/clipanion/lib/advanced/Command.mjs:49:26)
at async Cli.run (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/clipanion/lib/advanced/Cli.mjs:227:24)
at async Cli.runExit (file:///Users/emily.klassen/code/tmp/oapi-codegen-example/node_modules/clipanion/lib/advanced/Cli.mjs:236:28)
To work around this, i need to change the config like
// openapi-codegen.config.mts
import { defineConfig } from "@openapi-codegen/cli";
import {
generateSchemaTypes,
generateReactQueryComponents,
} from "@openapi-codegen/typescript";
export const example = defineConfig({
example: {
// can be overridden from cli
from: {
source: "github",
owner: "fabien0102",
repository: "openapi-codegen",
ref: "main",
specPath: "examples/spec.yaml",
},
// can be overridden from cli
outputDir: "src/queries",
to: async (context) => {
// You can transform the `context.openAPIDocument` here, can be useful to remove internal routes or fixing some known issues in the specs ;)
// Generate all the schemas types (components & responses)
const { schemasFiles } = await generateSchemaTypes(context, {
/* config */
});
// Generate all react-query components
await generateReactQueryComponents(context, {
/* config*/
schemasFiles,
});
},
},
}).example;
The primary motivation for using an mts file is, if i have a tsconfig which uses module: 'node16', the types will not resolve properly, as "@openapi-codegen/cli" et al are esm. Otherwise, i'd have to create another tsconfig specifically to target the config, which is less than ideal.
- 主要言語
- TypeScript
- スター
- 634
- フォーク
- 83
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fabien0102/openapi-codegen のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fabien0102/openapi-codegen#343 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fabien0102/openapi-codegen#342 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
fabien0102/openapi-codegen#356 ·
-
update dependencies & removed unused deprecated対応中かも @el-j が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
fabien0102/openapi-codegen#354 ·
-
deepMerge mutates its arguments, corrupting request payloads across calls対応中かも @richard-willis-chevin が 45 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
fabien0102/openapi-codegen#349 ·
fabien0102/openapi-codegen の issue をすべて見る
似ている issue
-
Add: YRF Music Nepalオープンstreams:add
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
walletbeat/walletbeat#1558 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
hawk-digital-environments/HAWKI#438 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
GiganticMinecraft/seichi-portal-frontend#1165 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信