Show classes in server endpoint #191

Merged
christian-monch merged 3 commits from classes-in-server-endpoint into master 2026-01-28 20:38:31 +00:00
3 changed files with 37 additions and 36 deletions

View file

@ -1,3 +1,12 @@
# 5.x.x (2026-01-28)
## New features
- The `/server`-endpoint result now contains the name of classes that are
supported by the collections, i.e., classes for which storage- and
validation-endpoints exist.
# 5.3.6 (2026-01-13) # 5.3.6 (2026-01-13)
## Changes ## Changes

View file

@ -101,6 +101,7 @@ class TokenCapabilityRequest(BaseModel):
class ServerCollectionResponse(BaseModel): class ServerCollectionResponse(BaseModel):
name: str name: str
schema: str schema: str
classes: list[str]
class ServerCollectionCountedResponse(ServerCollectionResponse): class ServerCollectionCountedResponse(ServerCollectionResponse):
@ -416,6 +417,7 @@ async def server() -> ServerResponse:
ServerCollectionResponse( ServerCollectionResponse(
name=collection_name, name=collection_name,
schema=g_instance_config.schemas[collection_name], schema=g_instance_config.schemas[collection_name],
classes=g_instance_config.model_info[collection_name][1],
) )
for collection_name in g_instance_config.collections for collection_name in g_instance_config.collections
] ]

View file

@ -392,50 +392,40 @@ def test_server(fastapi_client_simple):
response = test_client.get( response = test_client.get(
'/server', '/server',
) )
test_schema_classes = [
'Thing',
'Agent',
'InstantaneousEvent',
'Person',
]
flat_social_classes = [
'Thing',
'Property',
'ValueSpecification',
'FlatThing',
'FlatProperty',
'AnnotationTag',
'Organization',
'Person',
'Project',
]
assert response.status_code == HTTP_200_OK assert response.status_code == HTTP_200_OK
assert response.json() == { assert response.json() == {
'version': __version__, 'version': __version__,
'collections': [ 'collections': [
{ {
'name': 'collection_1', 'name': f'collection_{i}',
'schema': str(schema_file), 'schema': str(schema_file),
}, 'classes': test_schema_classes,
}
for i in range(1, 9)
] + [
{ {
'name': 'collection_2', 'name': f'collection_dlflatsocial-{i}',
'schema': str(schema_file),
},
{
'name': 'collection_3',
'schema': str(schema_file),
},
{
'name': 'collection_4',
'schema': str(schema_file),
},
{
'name': 'collection_5',
'schema': str(schema_file),
},
{
'name': 'collection_6',
'schema': str(schema_file),
},
{
'name': 'collection_7',
'schema': str(schema_file),
},
{
'name': 'collection_8',
'schema': str(schema_file),
},
{
'name': 'collection_dlflatsocial-1',
'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml', 'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml',
}, 'classes': flat_social_classes,
{ }
'name': 'collection_dlflatsocial-2', for i in range(1, 3)
'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml',
},
], ],
} }