Changing default case of schema properties
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- tooling
调研方向
Start with config.ts and the ConfigBase type, then trace how generateSchemaTypes and generateFetchers consume schema properties and required names. Decide whether casing belongs in configuration or a generation step, and define the expected behavior for both property and required names. The issue is done when the chosen behavior is implemented consistently and its scope is agreed.
由索引模型根据 Issue 内容生成。
描述
Hi,
I have a question about changing the case of generated schema properties.
Our OpenApi specification is generated from .NET API. Since all exported object properties have pascal case by default, generated schemas have also pascal, which is not TS/JS convention. It can be solved by these suggestions.
- Changing the case in
config.tsfile. This method is not ideal, but works.
to: async (context) => {
const filenamePrefix = 'api';
const { openAPIDocument: { components } } = context;
for (const schema of Object.values(components?.schemas || {})) {
if (!isSchemaObject(schema)) {
continue;
}
const { properties, required } = schema;
if (properties == null) {
continue;
}
for (const propertyName of Object.keys(properties)) {
const stored = properties[propertyName];
delete properties[propertyName]
properties[_.camelCase(propertyName)] = stored;
}
if (required != null) {
for (let i = 0; i < required.length; i++) {
const propertyName = required[i];
required[i] = _.camelCase(propertyName);
}
}
}
const { schemasFiles } = await generateSchemaTypes(context, {
filenamePrefix,
});
await generateFetchers(context, {
filenamePrefix,
schemasFiles,
});
},
- Adding a new config parameter to override casings. It may look like the example below. I can make a PR for that if necessary.
export type ConfigBase = {
...
filenameCase?: keyof Pick<typeof c, "snake" | "camel" | "kebab" | "pascal">;
casing?: {
schema?: {
property?: keyof Pick<typeof c, "snake" | "camel" | "kebab" | "pascal">;
}
}
};
Which option is better? If none, how should solve this issue?
Thx for your answers.
- 主要语言
- TypeScript
- 星标
- 634
- 派生
- 83
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 一周以上 新手友好度 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
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrently未关闭area:testing bug effort:S priority:P2
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
lens:agent lens:process process
难度 2/5 1-3 小时 新手友好度 82/100
thebristolsound/birdbrain#1772 ·
维护者通常 1 天内回复
-
bug priority:low ready-for-dev
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
Automattic/data-liberation-agent#685 ·
维护者通常 1 天内回复
-
Business
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复