Skip to content

Commit 300482c

Browse files
committed
py: fix field naming style for resourceType
1 parent 0a34d77 commit 300482c

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

examples/python/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (require.main === module) {
99
.python({
1010
allowExtraFields: false,
1111
staticDir: "./src/api/writer-generator/python/static-files",
12-
fieldFormat: "SnakeCase",
12+
fieldFormat: "snake_case",
1313
})
1414
.outputTo("./examples/python/fhir_types")
1515
.cleanOutput(true);

src/api/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class APIBuilder {
265265
const defaultPyOpts: PythonGeneratorOptions = {
266266
...defaultWriterOpts,
267267
rootPackageName: "fhir_types",
268-
fieldFormat: "SnakeCase",
268+
fieldFormat: "snake_case",
269269
};
270270

271271
const opts: PythonGeneratorOptions = {

src/api/writer-generator/python.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ const PRIMITIVE_TYPE_MAP: Record<string, string> = {
3838
xhtml: "str",
3939
};
4040

41-
type StringFormatKey = "SnakeCase" | "PascalCase" | "CamelCase" | "CapitalCase" | "KebabCase";
41+
type StringFormatKey = "snake_case" | "PascalCase" | "camelCase";
4242

4343
const AVAILABLE_STRING_FORMATS: Record<StringFormatKey, (str: string) => string> = {
44-
SnakeCase: snakeCase,
44+
snake_case: snakeCase,
4545
PascalCase: pascalCase,
46-
CamelCase: camelCase,
47-
CapitalCase: capitalCase,
48-
KebabCase: kebabCase,
46+
camelCase: camelCase,
4947
};
5048

5149
const PYTHON_KEYWORDS = new Set([
@@ -425,7 +423,7 @@ export class Python extends Writer<PythonGeneratorOptions> {
425423
}
426424

427425
private generateResourceTypeField(schema: RegularTypeSchema): void {
428-
this.line("resource_type: str = Field(");
426+
this.line(`${this.nameFormatFunction("resourceType")}: str = Field(`);
429427
this.indentBlock(() => {
430428
this.line(`default='${schema.identifier.name}',`);
431429
this.line(`alias='resourceType',`);

0 commit comments

Comments
 (0)