Skip to content

Commit f76e3dc

Browse files
committed
🐛 (settings) Fix api description loading from README.md
1 parent 32fa2a2 commit f76e3dc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

leakrfc/settings.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from anystore.io import smart_read
3+
from anystore.io import DoesNotExist, smart_read
44
from anystore.model import StoreModel
55
from pydantic import BaseModel, HttpUrl
66
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -40,6 +40,13 @@ class ApiContactSettings(BaseModel):
4040
email: str | None
4141

4242

43+
def get_api_doc() -> str:
44+
try:
45+
return smart_read("./README.md", "r")
46+
except DoesNotExist:
47+
return ""
48+
49+
4350
class ApiSettings(BaseSettings):
4451
model_config = SettingsConfigDict(
4552
env_prefix="leakrfc_api_",
@@ -52,7 +59,7 @@ class ApiSettings(BaseSettings):
5259
access_token_algorithm: str = "HS256"
5360

5461
title: str = "LeakRFC Api"
55-
description: str = smart_read("./README.md", mode="r")
62+
description: str = get_api_doc()
5663
contact: ApiContactSettings | None = None
5764

5865
allowed_origin: Optional[HttpUrl] = "http://localhost:3000"

0 commit comments

Comments
 (0)