diff --git a/CHANGELOG.md b/CHANGELOG.md index 545f9f7..6e76be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 5.3.0 (2025-12-02) + +## New features + +- The `/server`-endpoint result now contains the name of collections and the + schemas that are used by the collections. + + # 5.2.1 (2025-11-26) ## Changes diff --git a/README.md b/README.md index 078229a..f1b18fa 100644 --- a/README.md +++ b/README.md @@ -701,7 +701,17 @@ The service provides the following user endpoints (in addition to user-endpoints The response is a JSON object with the following structure: ```json { - "version": "" + "version": "", + "collections": [ + { + "name": "collection_1", + "schema": "https://example.org/schema_1.yaml" + }, + { + "name": "collection_2", + "schema": "https://example.org/schema_2.yaml" + }, + ] } ``` diff --git a/dump_things_service/__about__.py b/dump_things_service/__about__.py index 4dc2ef2..1d4672f 100644 --- a/dump_things_service/__about__.py +++ b/dump_things_service/__about__.py @@ -1 +1 @@ -__version__ = '5.2.1' +__version__ = '5.3.0' diff --git a/dump_things_service/main.py b/dump_things_service/main.py index 3c72f54..8fafc02 100644 --- a/dump_things_service/main.py +++ b/dump_things_service/main.py @@ -97,8 +97,18 @@ class TokenCapabilityRequest(BaseModel): token: str | None +class ServerCollectionResponse(BaseModel): + name: str + schema: str + + +class ServerCollectionCountedResponse(ServerCollectionResponse): + records: int + + class ServerResponse(BaseModel): version: str + collections: list[ServerCollectionResponse|ServerCollectionCountedResponse] logging.basicConfig(level=logging.WARNING) @@ -393,9 +403,16 @@ def validate_record( tags=['Server info'], name='get server information' ) -async def get_server() -> ServerResponse: +async def server() -> ServerResponse: return ServerResponse( version = __version__, + collections = [ + ServerCollectionResponse( + name=collection_name, + schema=g_instance_config.schemas[collection_name], + ) + for collection_name in g_instance_config.collections + ] ) diff --git a/dump_things_service/tests/test_basic.py b/dump_things_service/tests/test_basic.py index 8a52b00..4edb46c 100644 --- a/dump_things_service/tests/test_basic.py +++ b/dump_things_service/tests/test_basic.py @@ -1,3 +1,5 @@ +from pathlib import Path + import pytest # F401 from .. import ( @@ -14,6 +16,9 @@ from .create_store import ( ) from .test_utils import basic_write_locations +# Path to a local simple test schema +schema_file = Path(__file__).parent / 'testschema.yaml' + extra_record = { 'schema_type': 'abc:Person', 'pid': 'abc:aaaa', @@ -390,6 +395,48 @@ def test_server(fastapi_client_simple): assert response.status_code == HTTP_200_OK assert response.json() == { 'version': __version__, + 'collections': [ + { + 'name': 'collection_1', + 'schema': str(schema_file), + }, + { + 'name': 'collection_2', + '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', + }, + { + 'name': 'collection_dlflatsocial-2', + 'schema': 'https://concepts.datalad.org/s/flat-social/unreleased.yaml', + }, + ], }