Skip to content

Commit 5c4f28d

Browse files
committed
updates based on corrections in the spec
1 parent aba50c8 commit 5c4f28d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cnab/types.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,22 @@ def to_dict(self) -> dict:
210210

211211
@dataclass
212212
class Maintainer:
213+
name: str
213214
email: Optional[str] = None
214-
name: Optional[str] = None
215215
url: Optional[str] = None
216216

217217
@staticmethod
218218
def from_dict(obj: Any) -> "Maintainer":
219219
assert isinstance(obj, dict)
220-
email = from_union([from_str, from_none], obj.get("email"))
221220
name = from_union([from_str, from_none], obj.get("name"))
221+
email = from_union([from_str, from_none], obj.get("email"))
222222
url = from_union([from_str, from_none], obj.get("url"))
223-
return Maintainer(email, name, url)
223+
return Maintainer(name, email, url)
224224

225225
def to_dict(self) -> dict:
226226
result: dict = {}
227-
result["email"] = from_union([from_str, from_none], self.email)
228227
result["name"] = from_union([from_str, from_none], self.name)
228+
result["email"] = from_union([from_str, from_none], self.email)
229229
result["url"] = from_union([from_str, from_none], self.url)
230230
return clean(result)
231231

@@ -340,6 +340,7 @@ class Bundle:
340340
actions: Dict[str, Action] = field(default_factory=dict)
341341
credentials: Dict[str, Credential] = field(default_factory=dict)
342342
description: Optional[str] = None
343+
license: Optional[str] = None
343344
images: List[Image] = field(default_factory=list)
344345
keywords: List[str] = field(default_factory=list)
345346
maintainers: List[Maintainer] = field(default_factory=list)
@@ -356,6 +357,7 @@ def from_dict(obj: Any) -> "Bundle":
356357
obj.get("credentials"),
357358
)
358359
description = from_union([from_str, from_none], obj.get("description"))
360+
license = from_union([from_str, from_none], obj.get("license"))
359361
images = from_union(
360362
[lambda x: from_list(Image.from_dict, x), from_none], obj.get("images")
361363
)
@@ -384,6 +386,7 @@ def from_dict(obj: Any) -> "Bundle":
384386
actions,
385387
credentials,
386388
description,
389+
license,
387390
images,
388391
keywords,
389392
maintainers,
@@ -397,6 +400,7 @@ def to_dict(self) -> dict:
397400
lambda x: to_class(Credential, x), self.credentials
398401
)
399402
result["description"] = from_union([from_str, from_none], self.description)
403+
result["license"] = from_union([from_str, from_none], self.license)
400404
result["images"] = from_list(lambda x: to_class(Image, x), self.images)
401405
result["invocationImages"] = from_list(
402406
lambda x: to_class(InvocationImage, x), self.invocation_images

0 commit comments

Comments
 (0)