Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created March 17, 2020 05:49
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 cuongld2/f48366ee2a2457951ad8caa482478b32 to your computer and use it in GitHub Desktop.
Save cuongld2/f48366ee2a2457951ad8caa482478b32 to your computer and use it in GitHub Desktop.
pydantic base models
from typing import List
from pydantic import BaseModel
class UserInfoBase(BaseModel):
username: str
class UserCreate(UserInfoBase):
fullname: str
password: str
class UserAuthenticate(UserInfoBase):
password: str
class UserInfo(UserInfoBase):
id: int
class Config:
orm_mode = True
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
username: str = None
class BlogBase(BaseModel):
title: str
content: str
class Blog(BlogBase):
id: int
class Config:
orm_mode = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment