Added event response model in api documentation

This commit is contained in:
Donkie
2023-10-15 19:46:28 +02:00
parent a6d527aaf0
commit 7a3c2e3a68
3 changed files with 9 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ from pydantic import BaseModel, Field, validator
from pydantic.error_wrappers import ErrorWrapper from pydantic.error_wrappers import ErrorWrapper
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from spoolman.api.v1.models import Filament, Message from spoolman.api.v1.models import Filament, FilamentEvent, Message
from spoolman.database import filament from spoolman.database import filament
from spoolman.database.database import get_db_session from spoolman.database.database import get_db_session
from spoolman.database.utils import SortOrder from spoolman.database.utils import SortOrder
@@ -236,10 +236,10 @@ async def find(
name="Get filament", name="Get filament",
description=( description=(
"Get a specific filament. A websocket is served on the same path to listen for changes to the filament. " "Get a specific filament. A websocket is served on the same path to listen for changes to the filament. "
"The response model is the same for the websocket messages as for this endpoint." "See the HTTP Response code 299 for the content of the websocket messages."
), ),
response_model_exclude_none=True, response_model_exclude_none=True,
responses={404: {"model": Message}}, responses={404: {"model": Message}, 299: {"model": FilamentEvent, "description": "Websocket message"}},
) )
async def get( async def get(
db: Annotated[AsyncSession, Depends(get_db_session)], db: Annotated[AsyncSession, Depends(get_db_session)],

View File

@@ -13,7 +13,7 @@ from pydantic import BaseModel, Field
from pydantic.error_wrappers import ErrorWrapper from pydantic.error_wrappers import ErrorWrapper
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from spoolman.api.v1.models import Message, Spool from spoolman.api.v1.models import Message, Spool, SpoolEvent
from spoolman.database import spool from spoolman.database import spool
from spoolman.database.database import get_db_session from spoolman.database.database import get_db_session
from spoolman.database.utils import SortOrder from spoolman.database.utils import SortOrder
@@ -250,10 +250,10 @@ async def find(
name="Get spool", name="Get spool",
description=( description=(
"Get a specific spool. A websocket is served on the same path to listen for changes to the spool. " "Get a specific spool. A websocket is served on the same path to listen for changes to the spool. "
"The response model is the same for the websocket messages as for this endpoint." "See the HTTP Response code 299 for the content of the websocket messages."
), ),
response_model_exclude_none=True, response_model_exclude_none=True,
responses={404: {"model": Message}}, responses={404: {"model": Message}, 299: {"model": SpoolEvent, "description": "Websocket message"}},
) )
async def get( async def get(
db: Annotated[AsyncSession, Depends(get_db_session)], db: Annotated[AsyncSession, Depends(get_db_session)],

View File

@@ -11,7 +11,7 @@ from pydantic import BaseModel, Field
from pydantic.error_wrappers import ErrorWrapper from pydantic.error_wrappers import ErrorWrapper
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from spoolman.api.v1.models import Message, Vendor from spoolman.api.v1.models import Message, Vendor, VendorEvent
from spoolman.database import vendor from spoolman.database import vendor
from spoolman.database.database import get_db_session from spoolman.database.database import get_db_session
from spoolman.database.utils import SortOrder from spoolman.database.utils import SortOrder
@@ -104,10 +104,10 @@ async def find(
name="Get vendor", name="Get vendor",
description=( description=(
"Get a specific vendor. A websocket is served on the same path to listen for changes to the vendor. " "Get a specific vendor. A websocket is served on the same path to listen for changes to the vendor. "
"The response model is the same for the websocket messages as for this endpoint." "See the HTTP Response code 299 for the content of the websocket messages."
), ),
response_model_exclude_none=True, response_model_exclude_none=True,
responses={404: {"model": Message}}, responses={404: {"model": Message}, 299: {"model": VendorEvent, "description": "Websocket message"}},
) )
async def get( async def get(
db: Annotated[AsyncSession, Depends(get_db_session)], db: Annotated[AsyncSession, Depends(get_db_session)],