# HG changeset patch # User Sebastien Jodogne # Date 1609233857 -3600 # Node ID 9d6fa3da8f00b2827fd007c8b75f45fb96ba5e97 # Parent a4518adede595d4fadca4b0afad972d92fd33388 cont openapi diff -r a4518adede59 -r 9d6fa3da8f00 OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Mon Dec 28 17:40:35 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp Tue Dec 29 10:24:17 2020 +0100 @@ -1147,6 +1147,21 @@ static void ListPeers(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("List Orthanc peers") + .SetDescription("List all the Orthanc peers that are known to Orthanc. This corresponds either to the content of the " + "`OrthancPeers` configuration option, or to the information stored in the database if " + "`OrthancPeersInDatabase` is `true`.") + .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, + "If present, retrieve detailed information about the individual Orthanc peers", false) + .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the peers, or detailed information " + "about the peers (if `expand` argument is provided)"); + return; + } + OrthancConfiguration::ReaderLock lock; OrthancRestApi::SetOfStrings peers; @@ -1184,6 +1199,17 @@ static void ListPeerOperations(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("List operations on peer") + .SetDescription("List the operations that are available for an Orthanc peer.") + .SetUriArgument("id", "Orthanc identifier of the peer of interest") + .AddAnswerType(MimeType_Json, "List of the available operations"); + return; + } + OrthancConfiguration::ReaderLock lock; OrthancRestApi::SetOfStrings peers; @@ -1242,6 +1268,18 @@ static void PeerSystem(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("Get peer system information") + .SetDescription("Get system information about some Orthanc peer. This corresponds to doing a `GET` request " + "against the `/system` URI of the remote peer. This route can be used to test connectivity.") + .SetUriArgument("id", "Orthanc identifier of the peer of interest") + .AddAnswerType(MimeType_Json, "System information about the peer"); + return; + } + std::string remote = call.GetUriComponent("id", ""); OrthancConfiguration::ReaderLock lock; @@ -1272,6 +1310,24 @@ static void GetPeerConfiguration(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + Json::Value sample; + sample["HttpHeaders"] = Json::objectValue; + sample["Password"] = Json::nullValue; + sample["Pkcs11"] = false; + sample["Url"] = "http://127.0.1.1:5000/"; + sample["Username"] = "alice"; + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("Get peer configuration") + .SetDescription("Get detailed information about the configuration of some Orthanc peer.") + .SetUriArgument("id", "Orthanc identifier of the peer of interest") + .AddAnswerType(MimeType_Json, "Configuration of the peer") + .SetSample(sample); + return; + } + OrthancConfiguration::ReaderLock lock; const std::string peer = call.GetUriComponent("id", ""); @@ -1299,6 +1355,21 @@ static void ListModalities(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("List DICOM modalities") + .SetDescription("List all the DICOM modalities that are known to Orthanc. This corresponds either to the content of the " + "`DicomModalities` configuration option, or to the information stored in the database if " + "`DicomModalitiesInDatabase` is `true`.") + .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, + "If present, retrieve detailed information about the individual DICOM modalities", false) + .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the modalities, or detailed information " + "about the modalities (if `expand` argument is provided)"); + return; + } + OrthancConfiguration::ReaderLock lock; OrthancRestApi::SetOfStrings modalities; @@ -1333,6 +1404,17 @@ static void ListModalityOperations(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("List operations on modality") + .SetDescription("List the operations that are available for a DICOM modality.") + .SetUriArgument("id", "Orthanc identifier of the DICOM modality of interest") + .AddAnswerType(MimeType_Json, "List of the available operations"); + return; + } + OrthancConfiguration::ReaderLock lock; OrthancRestApi::SetOfStrings modalities; @@ -1374,6 +1456,17 @@ static void DeleteModality(RestApiDeleteCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("Delete DICOM modality") + .SetDescription("Delete one DICOM modality. This change is permanent iff. `DicomModalitiesInDatabase` is `true`, " + "otherwise it is lost at the next restart of Orthanc.") + .SetUriArgument("id", "Orthanc identifier of the DICOM modality of interest"); + return; + } + ServerContext& context = OrthancRestApi::GetContext(call); { @@ -1389,6 +1482,31 @@ static void GetModalityConfiguration(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + Json::Value sample; + sample["AET"] = "ORTHANCTEST"; + sample["AllowEcho"] = true; + sample["AllowEventReport"] = true; + sample["AllowFind"] = true; + sample["AllowGet"] = true; + sample["AllowMove"] = true; + sample["AllowNAction"] = true; + sample["AllowStore"] = true; + sample["AllowTranscoding"] = true; + sample["Host"] = "127.0.1.1"; + sample["Manufacturer"] = "Generic"; + sample["Port"] = 5001; + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("Get modality configuration") + .SetDescription("Get detailed information about the configuration of some DICOM modality.") + .SetUriArgument("id", "Orthanc identifier of the modality of interest") + .AddAnswerType(MimeType_Json, "Configuration of the modality") + .SetSample(sample); + return; + } + const std::string modality = call.GetUriComponent("id", ""); Json::Value answer; @@ -1426,6 +1544,17 @@ static void DeletePeer(RestApiDeleteCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("Networking") + .SetSummary("Delete Orthanc peer") + .SetDescription("Delete one Orthanc peer. This change is permanent iff. `OrthancPeersInDatabase` is `true`, " + "otherwise it is lost at the next restart of Orthanc.") + .SetUriArgument("id", "Orthanc identifier of the Orthanc peer of interest"); + return; + } + ServerContext& context = OrthancRestApi::GetContext(call); { diff -r a4518adede59 -r 9d6fa3da8f00 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Dec 28 17:40:35 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Dec 29 10:24:17 2020 +0100 @@ -1309,6 +1309,57 @@ static void GetResourceStatistics(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); + std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); + call.GetDocumentation() + .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */)) + .SetSummary("Get " + r + " statistics") + .SetDescription("Get statistics about the given " + r) + .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") + .SetAnswerField("DiskSize", RestApiCallDocumentation::Type_String, + "Size of the " + r + " on the disk in bytes, expressed as a string for 64bit compatibility with JSON") + .SetAnswerField("DiskSizeMB", RestApiCallDocumentation::Type_Number, + "Size of the " + r + " on the disk, expressed in megabytes (MB)") + .SetAnswerField("UncompressedSize", RestApiCallDocumentation::Type_String, + "Size of the " + r + " after decompression in bytes, expressed as a string for 64bit compatibility with JSON") + .SetAnswerField("UncompressedSizeMB", RestApiCallDocumentation::Type_Number, + "Size of the " + r + " after decompression, expressed in megabytes (MB). " + "This is different from `DiskSizeMB` iff `StorageCompression` is `true`.") + .SetAnswerField("DicomDiskSize", RestApiCallDocumentation::Type_String, + "Size on the disk of the DICOM instances associated with the " + r + ", expressed in bytes") + .SetAnswerField("DicomDiskSizeMB", RestApiCallDocumentation::Type_Number, + "Size on the disk of the DICOM instances associated with the " + r + ", expressed in megabytes (MB)") + .SetAnswerField("DicomUncompressedSize", RestApiCallDocumentation::Type_String, + "Size on the disk of the uncompressed DICOM instances associated with the " + r + ", expressed in bytes") + .SetAnswerField("DicomUncompressedSizeMB", RestApiCallDocumentation::Type_Number, + "Size on the disk of the uncompressed DICOM instances associated with the " + r + ", expressed in megabytes (MB)") + .SetHttpGetSample(GetDocumentationSampleResource(t) + "/statistics", true); + + switch (t) + { + // Do NOT add "break" below this point! + case ResourceType_Patient: + call.GetDocumentation().SetAnswerField("CountStudies", RestApiCallDocumentation::Type_Number, + "Number of child studies within this " + r); + + case ResourceType_Study: + call.GetDocumentation().SetAnswerField("CountSeries", RestApiCallDocumentation::Type_Number, + "Number of child series within this " + r); + + case ResourceType_Series: + call.GetDocumentation().SetAnswerField("CountInstances", RestApiCallDocumentation::Type_Number, + "Number of child instances within this " + r); + + case ResourceType_Instance: + default: + break; + } + + return; + } + static const uint64_t MEGA_BYTES = 1024 * 1024; std::string publicId = call.GetUriComponent("id", ""); @@ -1632,7 +1683,7 @@ .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */)) .SetSummary("Get attachment" + std::string(uncompress ? "" : " (no decompression)")) .SetDescription("Get the (binary) content of one attachment associated with the given " + r + - std::string(uncompress ? "" : ". The attachment will not be decompressed if `StorageCompression` if `true`.")) + std::string(uncompress ? "" : ". The attachment will not be decompressed if `StorageCompression` is `true`.")) .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") .SetUriArgument("name", "The name of the attachment, or its index (cf. `UserContentType` configuration option)") .AddAnswerType(MimeType_Binary, "The attachment"); diff -r a4518adede59 -r 9d6fa3da8f00 OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Mon Dec 28 17:40:35 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Tue Dec 29 10:24:17 2020 +0100 @@ -418,6 +418,18 @@ static void GetOrthancExplorerPlugins(RestApiGetCall& call) { + if (call.IsDocumentation()) + { + call.GetDocumentation() + .SetTag("System") + .SetSummary("JavaScript extensions to Orthanc Explorer") + .SetDescription("Get the JavaScript extensions that are installed by all the plugins using the " + "`OrthancPluginExtendOrthancExplorer()` function of the plugin SDK. " + "This route is for internal use of Orthanc Explorer.") + .AddAnswerType(MimeType_JavaScript, "The JavaScript extensions"); + return; + } + std::string s = "// Extensions to Orthanc Explorer by the registered plugins\n\n"; if (OrthancRestApi::GetContext(call).HasPlugins())