Skip to content

Commit

Permalink
fix: Add camelCased aliases to Pydantic models (#436)
Browse files Browse the repository at this point in the history
fix: add camel cased types to the frontend
  • Loading branch information
eric-nguyen-cs authored Mar 12, 2024
1 parent 14500cb commit d5d5944
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 41 deletions.
8 changes: 6 additions & 2 deletions backend/editor/models/base_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pydantic import BaseModel as PydanticBaseModel
from pydantic import ConfigDict, alias_generators


class BaseModel(PydanticBaseModel):
class Config:
arbitrary_types_allowed = True
model_config = ConfigDict(
alias_generator=alias_generators.to_camel,
arbitrary_types_allowed=True,
populate_by_name=True,
)
53 changes: 26 additions & 27 deletions backend/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1187,24 +1187,21 @@
"EntryNodeCreate": {
"properties": {
"name": { "type": "string", "title": "Name" },
"main_language_code": {
"type": "string",
"title": "Main Language Code"
}
"mainLanguageCode": { "type": "string", "title": "Mainlanguagecode" }
},
"type": "object",
"required": ["name", "main_language_code"],
"required": ["name", "mainLanguageCode"],
"title": "EntryNodeCreate"
},
"ErrorNode": {
"properties": {
"id": { "type": "string", "title": "Id" },
"taxonomy_name": { "type": "string", "title": "Taxonomy Name" },
"branch_name": { "type": "string", "title": "Branch Name" },
"created_at": {
"taxonomyName": { "type": "string", "title": "Taxonomyname" },
"branchName": { "type": "string", "title": "Branchname" },
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
"title": "Createdat"
},
"warnings": {
"items": { "type": "string" },
Expand All @@ -1220,9 +1217,9 @@
"type": "object",
"required": [
"id",
"taxonomy_name",
"branch_name",
"created_at",
"taxonomyName",
"branchName",
"createdAt",
"warnings",
"errors"
],
Expand All @@ -1248,36 +1245,38 @@
"allOf": [{ "$ref": "#/components/schemas/ProjectStatus" }],
"default": "LOADING"
},
"taxonomy_name": { "type": "string", "title": "Taxonomy Name" },
"branch_name": { "type": "string", "title": "Branch Name" },
"taxonomyName": { "type": "string", "title": "Taxonomyname" },
"branchName": { "type": "string", "title": "Branchname" },
"description": { "type": "string", "title": "Description" },
"is_from_github": { "type": "boolean", "title": "Is From Github" },
"created_at": {
"ownerName": { "type": "string", "title": "Ownername" },
"isFromGithub": { "type": "boolean", "title": "Isfromgithub" },
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
"title": "Createdat"
},
"github_checkout_commit_sha": {
"githubCheckoutCommitSha": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Github Checkout Commit Sha"
"title": "Githubcheckoutcommitsha"
},
"github_file_latest_sha": {
"githubFileLatestSha": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Github File Latest Sha"
"title": "Githubfilelatestsha"
},
"github_pr_url": {
"githubPrUrl": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Github Pr Url"
"title": "Githubprurl"
}
},
"type": "object",
"required": [
"id",
"taxonomy_name",
"branch_name",
"taxonomyName",
"branchName",
"description",
"is_from_github",
"created_at"
"ownerName",
"isFromGithub",
"createdAt"
],
"title": "Project"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/* eslint-disable */
export type EntryNodeCreate = {
name: string;
main_language_code: string;
mainLanguageCode: string;
};
6 changes: 3 additions & 3 deletions taxonomy-editor-frontend/src/client/models/ErrorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/* eslint-disable */
export type ErrorNode = {
id: string;
taxonomy_name: string;
branch_name: string;
created_at: string;
taxonomyName: string;
branchName: string;
createdAt: string;
warnings: Array<string>;
errors: Array<string>;
};
15 changes: 8 additions & 7 deletions taxonomy-editor-frontend/src/client/models/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import type { ProjectStatus } from "./ProjectStatus";
export type Project = {
id: string;
status: ProjectStatus;
taxonomy_name: string;
branch_name: string;
taxonomyName: string;
branchName: string;
description: string;
is_from_github: boolean;
created_at: string;
github_checkout_commit_sha?: string | null;
github_file_latest_sha?: string | null;
github_pr_url?: string | null;
ownerName: string;
isFromGithub: boolean;
createdAt: string;
githubCheckoutCommitSha?: string | null;
githubFileLatestSha?: string | null;
githubPrUrl?: string | null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CreateNodeDialogContent = ({
const handleAddEntryNode = () => {
setIsFailedSubmit(false);

const data = { name: newNodeName, main_language_code: newLanguageCode };
const data = { name: newNodeName, mainLanguageCode: newLanguageCode };

fetch(`${baseUrl}entry`, {
method: "POST",
Expand Down

0 comments on commit d5d5944

Please sign in to comment.