Support loading a config from a `openapi-codegen.config.mts` file
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 635
- Fork
- 82
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fabien0102/openapi-codegen
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#343 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#342 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
fabien0102/openapi-codegen#356 ·
-
update dependencies & removed unused deprecatedCó thể đã có người làm @el-j đã nhận 12 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
fabien0102/openapi-codegen#354 ·
-
deepMerge mutates its arguments, corrupting request payloads across callsCó thể đã có người làm @richard-willis-chevin đã nhận 56 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#349 ·
Tất cả issue của fabien0102/openapi-codegen
Issue tương tự
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Koenkk/zigbee-herdsman-converters#13540 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Tequila Music TV RO SDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
iptv-org/iptv#55821 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/busola/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
kyma-project/busola#5442 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vercel-labs/wterm#246 ·
Maintainer thường phản hồi trong vòng 1 ngày