api documentation

This commit is contained in:
Hayden
2021-01-07 19:54:49 -09:00
parent 53b4717810
commit 36db9f2e86
8 changed files with 175 additions and 41 deletions

View File

@@ -0,0 +1,56 @@
from typing import List, Optional
import pydantic
from pydantic.main import BaseModel
class RecipeResponse(BaseModel):
class Config:
schema_extra = {
"example": [
{
"slug": "crockpot-buffalo-chicken",
"image": "crockpot-buffalo-chicken.jpg",
"name": "Crockpot Buffalo Chicken",
},
{
"slug": "downtown-marinade",
"image": "downtown-marinade.jpg",
"name": "Downtown Marinade",
},
{
"slug": "detroit-style-pepperoni-pizza",
"image": "detroit-style-pepperoni-pizza.jpg",
"name": "Detroit-Style Pepperoni Pizza",
},
{
"slug": "crispy-carrots",
"image": "crispy-carrots.jpg",
"name": "Crispy Carrots",
},
]
}
class AllRecipeRequest(BaseModel):
properties: List[str]
limit: Optional[int]
class Config:
schema_extra = {
"example": {
"properties": ["name", "slug", "image"],
"limit": 100,
}
}
class RecipeURLIn(BaseModel):
class Config:
schema_extra = {"example": {"url": "https://myfavoriterecipes.com/recipes"}}
class SlugResponse(BaseModel):
class Config:
schema_extra = {
"example": "adult-mac-and-cheese"
}