r/FastAPI • u/raybesiga • Dec 11 '24
Question Cannot parse Scalar configuration and theme info to FastAPI
What happens? More on the Issue here.
I installed Scalar FastAPI
pip install scalar-fastapi and set up the main.py as per the documentation
from typing import Union
from fastapi import FastAPI
from scalar_fastapi import get_scalar_api_reference
app = FastAPI()
u/app.get("/")
def read_root():
return {"Hello": "World"}
u/app.get("/scalar", include_in_schema=False)
async def scalar_html():
return get_scalar_api_reference(
openapi_url=app.openapi_url,
title=app.title + " - Scalar",
)It works perfectly fine with the default FastAPI theme. I then try to change the theme by adding the config variable as below:
@app.get("/apidocs", include_in_schema=False)
async def scalar_html():
return get_scalar_api_reference(
openapi_url=app.openapi_url,
title=app.title,
theme="kepler",
)It returns Internal Server Error. The Docker logs show:
`TypeError: get_scalar_api_reference() got an unexpected keyword argument 'theme' What is the best way to add theme and configuration changes to Scalar for FastAPI?
3
Upvotes
View all comments
Show parent comment
1
u/raybesiga Dec 11 '24
Thank you u/fonixmunky I tried this with varied results:
- the `scalar_theme` options does not break the backend, which is great
- the value of `scalar_theme` does not matter as there is no observable change despite switching between the listed options, "alternate, default, moon, purple, solarized, bluePlanet, saturn, kepler, mars, deepSpace, none"
Seeing as the documentation says that the currently available configuration options are listed below, I am guessing it is by design.
layout(defaultLayout.MODERN)show_sidebar(defualttrue)hide_download_button(defaultfalse)hide_models(defaultfalse)dark_mode(defaulttrue)search_hot_key(defaultSearchHotKey.K)hidden_clients(default[])servers(default[])default_open_all_tags(defaultfalse)Thanks again for the pointer.