Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created March 3, 2021 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/f97cafefc70dc0ad1373c18a26980272 to your computer and use it in GitHub Desktop.
Save MartinThoma/f97cafefc70dc0ad1373c18a26980272 to your computer and use it in GitHub Desktop.
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