Created
March 3, 2021 22:55
-
-
Save MartinThoma/f97cafefc70dc0ad1373c18a26980272 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from pydantic import BaseModel | |
class GitlabUser(BaseModel): | |
id: int | |
username: str | |
class GitlabMr(BaseModel): | |
id: int | |
squash: bool | |
web_url: str | |
title: str | |
author: GitlabUser | |
mr = GitlabMr( | |
id=1, | |
squash=True, | |
web_url="http://foo", | |
title="title", | |
author=GitlabUser(id=42, username="Joe"), | |
) | |
json_str = mr.json() | |
print(json_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment