Last active
August 9, 2021 14:55
-
-
Save chunleng/a75f7774319bd0f18a293e8dd32807b7 to your computer and use it in GitHub Desktop.
Medium: OpenAPI and CodeGen - FastAPI
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 fastapi import FastAPI | |
from fastapi.middleware.cors import CORSMiddleware | |
from fastapi.responses import JSONResponse | |
from pydantic import BaseModel | |
app = FastAPI() | |
app.add_middleware(CORSMiddleware, allow_origins=['*']) | |
class Bar(BaseModel): | |
items: list[str] = [] | |
@app.get('/GetFoo', operation_id='GetFoo', | |
response_class=JSONResponse, response_model=Bar, tags=['First']) | |
async def get_foo(): | |
return Bar(items=[1,2,3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment