Skip to content

Commit 1a60304

Browse files
committed
Update
1 parent 6f11263 commit 1a60304

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

data_contract_specification.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ class DataContractSpecification(pyd.BaseModel):
307307
links: Dict[str, str] = {}
308308
tags: List[str] = []
309309

310+
def to_yaml(self) -> str:
311+
return yaml.dump(
312+
self.model_dump(exclude_defaults=True, exclude_none=True,
313+
by_alias=True),
314+
sort_keys=False,
315+
allow_unicode=True,
316+
)
317+
310318
@classmethod
311319
def from_file(cls, file_path: str) -> "DataContractSpecification":
312320
if not os.path.exists(file_path):
@@ -320,14 +328,6 @@ def from_string(cls, data_contract_str: str) -> "DataContractSpecification":
320328
data = yaml.safe_load(data_contract_str)
321329
return cls(**data)
322330

323-
def to_yaml(self) -> str:
324-
return yaml.dump(
325-
self.model_dump(exclude_defaults=True, exclude_none=True,
326-
by_alias=True),
327-
sort_keys=False,
328-
allow_unicode=True,
329-
)
330-
331331
@classmethod
332332
def json_schema(cls):
333333
package_name = __name__.split('.')[0]

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "datacontract-specification-python"
2+
name = "datacontract-specification"
33
version = "1.1.0" # in sync with spec
44
description = "The Pydantic Model of the Data Contract Specification"
55
readme = "README.md"

0 commit comments

Comments
 (0)