Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def __modify_schema__(
cls, field_schema: dict[str, Any], field: ModelField | None
):
if field:
field_schema.update({field.name: repr(target)})
field_schema.update(
{"type": f"{target.__module__}.{target.__qualname__}"}
)

self._reference_cache[target] = Reference

Expand Down
14 changes: 14 additions & 0 deletions tests/core/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ def test_add_plan(empty_context: BlueskyContext, plan: PlanGenerator) -> None:
assert plan.__name__ in empty_context.plans


def test_generated_schema(
empty_context: BlueskyContext,
):
def demo_plan(foo: int, mov: Movable) -> MsgGenerator: # type: ignore
...

empty_context.plan(demo_plan)
schema = empty_context.plans["demo_plan"].model.schema()
assert schema["properties"] == {
"foo": {"title": "Foo", "type": "integer"},
"mov": {"title": "Mov", "type": "bluesky.protocols.Movable"},
}


@pytest.mark.parametrize(
"plan", [has_typeless_param, has_typed_and_typeless_params, has_typeless_params]
)
Expand Down
6 changes: 2 additions & 4 deletions tests/service/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def test_get_plan_with_device_reference(handler: Handler, client: TestClient) ->
"title": "Delay",
},
"detectors": {
"items": {
"_detectors": "<class " "'bluesky.protocols.Readable'>"
},
"items": {"type": "bluesky.protocols.Readable"},
"title": "Detectors",
"type": "array",
},
Expand All @@ -135,7 +133,7 @@ def test_get_plan_with_device_reference(handler: Handler, client: TestClient) ->
"title": "Delay",
},
"detectors": {
"items": {"_detectors": "<class " "'bluesky.protocols.Readable'>"},
"items": {"type": "bluesky.protocols.Readable"},
"title": "Detectors",
"type": "array",
},
Expand Down