# HG changeset patch # User Alain Mazy # Date 1697547971 -7200 # Node ID 62bb63346185877e902c8f7ca9dc029c0325cee2 # Parent 7bae5f7ebe6a952ee4f9f084f076de6f7690f6c8 All 'expand' GET arguments now accepts expand=true and expand=false values + /studies/../instances now supports expand=false diff -r 7bae5f7ebe6a -r 62bb63346185 NEWS --- a/NEWS Tue Oct 17 10:31:21 2023 +0200 +++ b/NEWS Tue Oct 17 15:06:11 2023 +0200 @@ -14,6 +14,10 @@ * API version upgraded to 22 * Added a route to delete completed jobs from history: DELETE /jobs/{id} +* All 'expand' GET arguments now accepts expand=true and expand=false values. + The /studies/../instances and sibling routes are the only whose expand is true if not specified. + These routes now accepts expand=false to simply list the child resources ids. + Maintenance ----------- diff -r 7bae5f7ebe6a -r 62bb63346185 OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Tue Oct 17 10:31:21 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Tue Oct 17 15:06:11 2023 +0200 @@ -843,7 +843,7 @@ return; } - const bool expand = call.HasArgument("expand"); + const bool expand = call.HasArgument("expand") && call.GetBooleanArgument("expand", true); const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Full); QueryAccessor query(call); @@ -1649,7 +1649,7 @@ OrthancRestApi::SetOfStrings peers; lock.GetConfiguration().GetListOfOrthancPeers(peers); - if (call.HasArgument("expand")) + if (call.HasArgument("expand") && call.GetBooleanArgument("expand", true)) { Json::Value result = Json::objectValue; for (OrthancRestApi::SetOfStrings::const_iterator @@ -1933,7 +1933,7 @@ OrthancRestApi::SetOfStrings modalities; lock.GetConfiguration().GetListOfDicomModalities(modalities); - if (call.HasArgument("expand")) + if (call.HasArgument("expand") && call.GetBooleanArgument("expand", true)) { Json::Value result = Json::objectValue; for (OrthancRestApi::SetOfStrings::const_iterator diff -r 7bae5f7ebe6a -r 62bb63346185 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Oct 17 10:31:21 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Oct 17 15:06:11 2023 +0200 @@ -254,7 +254,7 @@ index.GetAllUuids(result, resourceType); } - AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand"), + AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand") && call.GetBooleanArgument("expand", true), OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human), requestedTags, true /* allowStorageAccess */); @@ -1701,7 +1701,7 @@ bool isNumeric = call.HasArgument("numeric"); - if (call.HasArgument("expand")) + if (call.HasArgument("expand") && call.GetBooleanArgument("expand", true)) { result = Json::objectValue; @@ -3324,12 +3324,15 @@ .SetDescription("Get detailed information about the child " + children + " of the DICOM " + resource + " whose Orthanc identifier is provided in the URL") .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest") + .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, + "If false or missing, only retrieve the list of child " + children, false) .AddAnswerType(MimeType_Json, "JSON array containing information about the child DICOM " + children) .SetTruncatedJsonHttpGetSample(GetDocumentationSampleResource(start) + "/" + children, 5); return; } ServerIndex& index = OrthancRestApi::GetIndex(call); + ServerContext& context = OrthancRestApi::GetContext(call); std::set requestedTags; OrthancRestApi::GetRequestedTags(requestedTags, call); @@ -3355,21 +3358,10 @@ a.splice(a.begin(), b); } - Json::Value result = Json::arrayValue; - - const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human); - - for (std::list::const_iterator - it = a.begin(); it != a.end(); ++it) - { - Json::Value resource; - if (OrthancRestApi::GetContext(call).ExpandResource(resource, *it, end, format, requestedTags, true /* allowStorageAccess */)) - { - result.append(resource); - } - } - - call.GetOutput().AnswerJson(result); + AnswerListOfResources(call.GetOutput(), context, a, type, !call.HasArgument("expand") || call.GetBooleanArgument("expand", false), // this "expand" is the only one to have a false default value to keep backward compatibility + OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human), + requestedTags, + true /* allowStorageAccess */); } diff -r 7bae5f7ebe6a -r 62bb63346185 OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Tue Oct 17 10:31:21 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Tue Oct 17 15:06:11 2023 +0200 @@ -657,7 +657,7 @@ return; } - bool expand = call.HasArgument("expand"); + bool expand = call.HasArgument("expand") && call.GetBooleanArgument("expand", true); Json::Value v = Json::arrayValue;