diff --git a/Development/cmake/NmosCppLibraries.cmake b/Development/cmake/NmosCppLibraries.cmake index ecf845a14..c255d6c15 100644 --- a/Development/cmake/NmosCppLibraries.cmake +++ b/Development/cmake/NmosCppLibraries.cmake @@ -700,7 +700,7 @@ set(NMOS_IS13_V1_0_SCHEMAS_JSON third_party/is-13/${NMOS_IS13_V1_0_TAG}/APIs/schemas/error.json third_party/is-13/${NMOS_IS13_V1_0_TAG}/APIs/schemas/resource_core.json third_party/is-13/${NMOS_IS13_V1_0_TAG}/APIs/schemas/resource_core_patch.json - third_party/is-13/${NMOS_IS13_V1_0_TAG}/APIs/schemas/resource_cores.json + third_party/is-13/${NMOS_IS13_V1_0_TAG}/APIs/schemas/resource-list.json ) set(NMOS_IS13_SCHEMAS_JSON_MATCH "third_party/is-13/([^/]+)/APIs/schemas/([^;]+)\\.json") diff --git a/Development/nmos/annotation_api.cpp b/Development/nmos/annotation_api.cpp index 0f71a3e45..9857cff90 100644 --- a/Development/nmos/annotation_api.cpp +++ b/Development/nmos/annotation_api.cpp @@ -248,13 +248,28 @@ namespace nmos size_t count = 0; - set_reply(res, status_codes::OK, - web::json::serialize_array(resources - | boost::adaptors::filtered(match) - | boost::adaptors::transformed( - [&count](const nmos::resources::value_type& resource) { ++count; return nmos::make_annotation_response(resource); } - )), - web::http::details::mime_types::application_json); + // experimental extension, to support human-readable HTML rendering of NMOS responses + if (experimental::details::is_html_response_preferred(req, web::http::details::mime_types::application_json)) + { + set_reply(res, status_codes::OK, + web::json::serialize_array(resources + | boost::adaptors::filtered(match) + | boost::adaptors::transformed( + [&count, &req](const nmos::resource& resource) { ++count; return experimental::details::make_html_response_a_tag(resource.id + U("/"), req); } + )), + web::http::details::mime_types::application_json); + } + else + { + set_reply(res, status_codes::OK, + web::json::serialize_array(resources + | boost::adaptors::filtered(match) + | boost::adaptors::transformed( + [&count](const nmos::resource& resource) { ++count; return value(resource.id + U("/")); } + ) + ), + web::http::details::mime_types::application_json); + } slog::log(gate, SLOG_FLF) << "Returning " << count << " matching " << resourceType; diff --git a/Development/nmos/is13_schemas/is13_schemas.h b/Development/nmos/is13_schemas/is13_schemas.h index 85396e8fb..6a3f76634 100644 --- a/Development/nmos/is13_schemas/is13_schemas.h +++ b/Development/nmos/is13_schemas/is13_schemas.h @@ -14,7 +14,7 @@ namespace nmos extern const char* error; extern const char* resource_core; extern const char* resource_core_patch; - extern const char* resource_cores; + extern const char* resource_list; } } } diff --git a/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource-list.json b/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource-list.json new file mode 100644 index 000000000..7239fc400 --- /dev/null +++ b/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource-list.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "type": "array", + "description": "List of resource ID paths", + "title": "Resources base resource", + "items": { + "type": "string", + "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/$" + }, + "uniqueItems": true +} diff --git a/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource_cores.json b/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource_cores.json deleted file mode 100644 index e71271693..000000000 --- a/Development/third_party/is-13/v1.0-dev/APIs/schemas/resource_cores.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "array", - "description": "A list of resources", - "title": "Collection of resources", - "items": { - "$ref": "resource_core.json" - }, - "uniqueItems": true -}