pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
457 B
14 lines
457 B
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
def test_allow_async_openapi():
|
|
async def async_openapi():
|
|
return {"foo": "bar"}
|
|
|
|
mod_app = FastAPI() # use fresh instance to not affect other tests
|
|
mod_app.openapi = async_openapi
|
|
mod_client = TestClient(mod_app)
|
|
response = mod_client.get("/openapi.json")
|
|
assert response.status_code == 200, response.text
|
|
assert response.json() == {"foo": "bar"}
|
|
|