Skip to content

Commit bc4e2bb

Browse files
committed
add json mixin
1 parent 8ab4d15 commit bc4e2bb

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

generate_schemas.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ async function return_json_schema(directoryPath, folder_path, projectName) {
105105
filename,
106106
fileContent
107107
);
108-
const pythonContent = jsonTypes.join("\n");
108+
let pythonContent =
109+
"from dataclasses_json import DataClassJsonMixin\n" +
110+
jsonTypes.join("\n");
111+
pythonContent = pythonContent.replace(
112+
/@dataclass\nclass (\w+)(?:\s*\([^)]*\))?\s*:/g,
113+
"@dataclass\nclass $1(DataClassJsonMixin):"
114+
);
109115
const pythonFile = path.join(folder.path, filename + ".py");
110116
fs.writeFileSync(pythonFile, pythonContent);
111117
} catch (error) {

requirements.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
SQLAlchemy==2.0.43
2-
fastjsonschema==2.21.1
2+
fastjsonschema==2.21.1
3+
dataclasses_json==0.6.7

0 commit comments

Comments
 (0)