Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Changing default case of schema properties

オープン
#118 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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.ts file. 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fabien0102/openapi-codegen のほかの issue

fabien0102/openapi-codegen の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。