start making optional attributes look better in redoc
This commit is contained in:
parent
c8ec578045
commit
ea335a8fe8
2 changed files with 21 additions and 8 deletions
|
@ -15,8 +15,15 @@ GeometryStylesSchema = Annotated[
|
|||
APIField(description="mapping with a color for each feature type")
|
||||
]
|
||||
EditorID = Union[
|
||||
Annotated[PositiveInt, APIField(title="an existing object that might have been modified in this changeset")],
|
||||
Annotated[str, APIField(pattern="^c:[0-9]+$", title="an object that was created in this changeset")],
|
||||
Annotated[PositiveInt, APIField(
|
||||
title="existing object",
|
||||
description="ID of an existing object that might have been modified in this changeset"
|
||||
)],
|
||||
Annotated[str, APIField(
|
||||
pattern="^c:[0-9]+$",
|
||||
title="created object",
|
||||
description="id of an object that was created in this changeset"
|
||||
)],
|
||||
]
|
||||
EditorGeometriesUpdateCacheKeyElem = Annotated[
|
||||
tuple[
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
from typing import Annotated, Optional
|
||||
from typing import Annotated, Optional, Union
|
||||
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.shortcuts import redirect
|
||||
|
@ -8,6 +8,7 @@ from ninja import Query
|
|||
from ninja import Router as APIRouter
|
||||
from ninja import Schema
|
||||
from pydantic import Field as APIField
|
||||
from pydantic import PositiveInt
|
||||
|
||||
from c3nav.api.auth import auth_permission_responses, auth_responses, validate_responses
|
||||
from c3nav.api.exceptions import API404, APIPermissionDenied, APIRequestValidationFailed
|
||||
|
@ -270,15 +271,20 @@ def get_position_by_id(request, position_id: AnyPositionID):
|
|||
raise API404()
|
||||
return location.serialize_position()
|
||||
|
||||
|
||||
class UpdatePositionSchema(Schema):
|
||||
coordinates_id: Optional[CustomLocationID] = APIField(
|
||||
description="coordinates to set the location to or None to unset it"
|
||||
coordinates_id: Union[
|
||||
Annotated[CustomLocationID, APIField(title="set coordinates")],
|
||||
Annotated[None, APIField(title="unset coordinates")],
|
||||
] = APIField(
|
||||
description="coordinates to set the location to or null to unset it"
|
||||
)
|
||||
timeout: Optional[int] = APIField(
|
||||
timeout: Union[
|
||||
Annotated[PositiveInt, APIField(title="new timeout")],
|
||||
Annotated[None, APIField(title="don't change")],
|
||||
] = APIField(
|
||||
None,
|
||||
title="timeout",
|
||||
description="timeout for this new location in seconds, or None if not to change it",
|
||||
example=None,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue