Skip to content

Instantly share code, notes, and snippets.

@Montgoner
Created February 19, 2021 15:56
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 Montgoner/5cb9256632b559da5c1cb387f8fc3283 to your computer and use it in GitHub Desktop.
Save Montgoner/5cb9256632b559da5c1cb387f8fc3283 to your computer and use it in GitHub Desktop.
from fastapi import FastAPI
from fastapi_versioning import VersionedFastAPI, version
app = FastAPI(title="My App")
@app.get("/greet")
@version(1, 0)
def greet_with_hello():
return "Hello"
@app.get("/greet")
@version(1, 2)
def greet_with_hi():
return "Hi"
@app.get("/goodbye")
@version(1, 1)
def say_goodbye():
return “bye”
@app.get("/foo")
def get_foo():
return “foo”
app = VersionedFastAPI(app, default_api_version=(1, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment