-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to add tojson method to instance classes via decorator
- Loading branch information
Showing
2 changed files
with
17 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
import json | ||
|
||
from marshmallow import Schema, fields | ||
from marshmallow_jsonschema import JSONSchema | ||
|
||
from neomodel import StringProperty | ||
from src.Models.DataObject.v0_0_2.DataObject import DataObject | ||
|
||
|
||
@has_json_schema | ||
class String(DataObject): | ||
stringValue = StringProperty(unique_index=True, required=True) | ||
|
||
def toJSON(self): | ||
return json.dumps(self, default=lambda o: o.__dict__) | ||
|
||
def getSchema(self): | ||
string_schema = StringSchema() | ||
json_schema = JSONSchema() | ||
return json_schema.dump(string_schema) | ||
|
||
|
||
class StringSchema(Schema): | ||
stringValue = fields.String(required=True) |