Skip to content

Commit

Permalink
Add schemas for most UWS routes
Browse files Browse the repository at this point in the history
Provide a schema for the routes returning vo-models Pydantic XML
models. These may not be entirely correct for the XML schema, but
they seem better than nothing. Do not return a schema for the
`/parameters` route, since we don't have easy access to the correct
parameters model in the handler.
  • Loading branch information
rra committed Dec 7, 2024
1 parent 95dc7e1 commit 81fe8c8
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions safir/src/safir/uws/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from fastapi import APIRouter, Depends, Form, Query, Request, Response
from fastapi.responses import PlainTextResponse, RedirectResponse
from structlog.stdlib import BoundLogger
from vo_models.uws import Jobs, JobSummary, Results
from vo_models.uws.types import ExecutionPhase

from safir.datetime import isodatetime
Expand Down Expand Up @@ -51,7 +52,13 @@
"List all existing jobs for the current user. Jobs will be sorted"
" by creation date, with the most recently created listed first."
),
responses={200: {"content": {"application/xml": {}}}},
responses={
200: {
"content": {
"application/xml": {"schema": Jobs.model_json_schema()}
}
}
},
summary="Async job list",
)
async def get_job_list(
Expand Down Expand Up @@ -95,7 +102,13 @@ async def get_job_list(

@uws_router.get(
"/{job_id}",
responses={200: {"content": {"application/xml": {}}}},
responses={
200: {
"content": {
"application/xml": {"schema": JobSummary.model_json_schema()}
}
}
},
summary="Job details",
)
async def get_job(
Expand Down Expand Up @@ -227,7 +240,7 @@ async def post_job_destruction(
@uws_router.get(
"/{job_id}/error",
responses={
200: {"content": {"application/xml": {}}},
200: {"content": {"application/x-votable+xml": {}}},
404: {"description": "Job not found or job did not fail"},
},
summary="Job error",
Expand Down Expand Up @@ -396,7 +409,13 @@ async def get_job_quote(

@uws_router.get(
"/{job_id}/results",
responses={200: {"content": {"application/xml": {}}}},
responses={
200: {
"content": {
"application/xml": {"schema": Results.model_json_schema()}
}
}
},
summary="Job results",
)
async def get_job_results(
Expand Down

0 comments on commit 81fe8c8

Please sign in to comment.