Skip to content

Commit d5d5944

Browse files
fix: Add camelCased aliases to Pydantic models (#436)
fix: add camel cased types to the frontend
1 parent 14500cb commit d5d5944

File tree

6 files changed

+45
-41
lines changed

6 files changed

+45
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from pydantic import BaseModel as PydanticBaseModel
2+
from pydantic import ConfigDict, alias_generators
23

34

45
class BaseModel(PydanticBaseModel):
5-
class Config:
6-
arbitrary_types_allowed = True
6+
model_config = ConfigDict(
7+
alias_generator=alias_generators.to_camel,
8+
arbitrary_types_allowed=True,
9+
populate_by_name=True,
10+
)

backend/openapi/openapi.json

+26-27
Original file line numberDiff line numberDiff line change
@@ -1187,24 +1187,21 @@
11871187
"EntryNodeCreate": {
11881188
"properties": {
11891189
"name": { "type": "string", "title": "Name" },
1190-
"main_language_code": {
1191-
"type": "string",
1192-
"title": "Main Language Code"
1193-
}
1190+
"mainLanguageCode": { "type": "string", "title": "Mainlanguagecode" }
11941191
},
11951192
"type": "object",
1196-
"required": ["name", "main_language_code"],
1193+
"required": ["name", "mainLanguageCode"],
11971194
"title": "EntryNodeCreate"
11981195
},
11991196
"ErrorNode": {
12001197
"properties": {
12011198
"id": { "type": "string", "title": "Id" },
1202-
"taxonomy_name": { "type": "string", "title": "Taxonomy Name" },
1203-
"branch_name": { "type": "string", "title": "Branch Name" },
1204-
"created_at": {
1199+
"taxonomyName": { "type": "string", "title": "Taxonomyname" },
1200+
"branchName": { "type": "string", "title": "Branchname" },
1201+
"createdAt": {
12051202
"type": "string",
12061203
"format": "date-time",
1207-
"title": "Created At"
1204+
"title": "Createdat"
12081205
},
12091206
"warnings": {
12101207
"items": { "type": "string" },
@@ -1220,9 +1217,9 @@
12201217
"type": "object",
12211218
"required": [
12221219
"id",
1223-
"taxonomy_name",
1224-
"branch_name",
1225-
"created_at",
1220+
"taxonomyName",
1221+
"branchName",
1222+
"createdAt",
12261223
"warnings",
12271224
"errors"
12281225
],
@@ -1248,36 +1245,38 @@
12481245
"allOf": [{ "$ref": "#/components/schemas/ProjectStatus" }],
12491246
"default": "LOADING"
12501247
},
1251-
"taxonomy_name": { "type": "string", "title": "Taxonomy Name" },
1252-
"branch_name": { "type": "string", "title": "Branch Name" },
1248+
"taxonomyName": { "type": "string", "title": "Taxonomyname" },
1249+
"branchName": { "type": "string", "title": "Branchname" },
12531250
"description": { "type": "string", "title": "Description" },
1254-
"is_from_github": { "type": "boolean", "title": "Is From Github" },
1255-
"created_at": {
1251+
"ownerName": { "type": "string", "title": "Ownername" },
1252+
"isFromGithub": { "type": "boolean", "title": "Isfromgithub" },
1253+
"createdAt": {
12561254
"type": "string",
12571255
"format": "date-time",
1258-
"title": "Created At"
1256+
"title": "Createdat"
12591257
},
1260-
"github_checkout_commit_sha": {
1258+
"githubCheckoutCommitSha": {
12611259
"anyOf": [{ "type": "string" }, { "type": "null" }],
1262-
"title": "Github Checkout Commit Sha"
1260+
"title": "Githubcheckoutcommitsha"
12631261
},
1264-
"github_file_latest_sha": {
1262+
"githubFileLatestSha": {
12651263
"anyOf": [{ "type": "string" }, { "type": "null" }],
1266-
"title": "Github File Latest Sha"
1264+
"title": "Githubfilelatestsha"
12671265
},
1268-
"github_pr_url": {
1266+
"githubPrUrl": {
12691267
"anyOf": [{ "type": "string" }, { "type": "null" }],
1270-
"title": "Github Pr Url"
1268+
"title": "Githubprurl"
12711269
}
12721270
},
12731271
"type": "object",
12741272
"required": [
12751273
"id",
1276-
"taxonomy_name",
1277-
"branch_name",
1274+
"taxonomyName",
1275+
"branchName",
12781276
"description",
1279-
"is_from_github",
1280-
"created_at"
1277+
"ownerName",
1278+
"isFromGithub",
1279+
"createdAt"
12811280
],
12821281
"title": "Project"
12831282
},

taxonomy-editor-frontend/src/client/models/EntryNodeCreate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
/* eslint-disable */
55
export type EntryNodeCreate = {
66
name: string;
7-
main_language_code: string;
7+
mainLanguageCode: string;
88
};

taxonomy-editor-frontend/src/client/models/ErrorNode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
/* eslint-disable */
55
export type ErrorNode = {
66
id: string;
7-
taxonomy_name: string;
8-
branch_name: string;
9-
created_at: string;
7+
taxonomyName: string;
8+
branchName: string;
9+
createdAt: string;
1010
warnings: Array<string>;
1111
errors: Array<string>;
1212
};

taxonomy-editor-frontend/src/client/models/Project.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import type { ProjectStatus } from "./ProjectStatus";
66
export type Project = {
77
id: string;
88
status: ProjectStatus;
9-
taxonomy_name: string;
10-
branch_name: string;
9+
taxonomyName: string;
10+
branchName: string;
1111
description: string;
12-
is_from_github: boolean;
13-
created_at: string;
14-
github_checkout_commit_sha?: string | null;
15-
github_file_latest_sha?: string | null;
16-
github_pr_url?: string | null;
12+
ownerName: string;
13+
isFromGithub: boolean;
14+
createdAt: string;
15+
githubCheckoutCommitSha?: string | null;
16+
githubFileLatestSha?: string | null;
17+
githubPrUrl?: string | null;
1718
};

taxonomy-editor-frontend/src/components/CreateNodeDialogContent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const CreateNodeDialogContent = ({
3333
const handleAddEntryNode = () => {
3434
setIsFailedSubmit(false);
3535

36-
const data = { name: newNodeName, main_language_code: newLanguageCode };
36+
const data = { name: newNodeName, mainLanguageCode: newLanguageCode };
3737

3838
fetch(`${baseUrl}entry`, {
3939
method: "POST",

0 commit comments

Comments
 (0)