From e433b6aa5c16cd1d68c29875a10f4dc4e406955c Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 24 Mar 2026 13:47:58 +0100 Subject: [PATCH] Minor fixes to OpenAPI --- broker/JFJochBrokerHttp.cpp | 17 ++++++++++------- broker/jfjoch_api.yaml | 4 ++++ broker/redoc-static.html | 4 +++- docs/python_client/docs/DefaultApi.md | 2 ++ frontend/src/openapi/services/DefaultService.ts | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/broker/JFJochBrokerHttp.cpp b/broker/JFJochBrokerHttp.cpp index 645e7766..d7a4b6db 100644 --- a/broker/JFJochBrokerHttp.cpp +++ b/broker/JFJochBrokerHttp.cpp @@ -9,6 +9,7 @@ #include #include +#include "Helpers.h" #include "../common/GitInfo.h" #include "../preview/JFJochTIFF.h" #include "OpenAPIConvert.h" @@ -108,6 +109,8 @@ std::pair JFJochBrokerHttp::handleParsingException(const std:: throw; } catch (const nlohmann::detail::exception &e) { return {400, e.what()}; + } catch (const org::openapitools::server::helpers::ValidationException &e) { + return {400, e.what()}; } catch (const std::exception &e) { return {500, e.what()}; } @@ -547,8 +550,6 @@ void JFJochBrokerHttp::statistics_get(const std::optional &compression, ht statistics.setZeromqMetadata(Convert(zeromq_metadata)); nlohmann::json j = statistics; - if (!compression.has_value() || compression.value()) - response.set_header("Content-Encoding", "deflate"); response.set_content(j.dump(), "application/json"); response.status = 200; @@ -636,7 +637,7 @@ void JFJochBrokerHttp::image_buffer_image_jpeg_get(const std::optional int64_t image_id = id.value_or(ImageBuffer::MaxImage); PreviewImageSettings settings{}; - settings.show_user_mask = showUserMask.value_or(true); + settings.show_user_mask = showUserMask.value_or(false); settings.show_roi = showRoi.value_or(false); settings.show_spots = showSpots.value_or(true); settings.saturation_value = saturation; @@ -819,7 +820,7 @@ void JFJochBrokerHttp::preview_plot_bin_get(const std::optional &ty state_machine.GetPlotRaw(ret, ConvertPlotType(type), roi.value_or("")); if (ret.empty()) { - response.status = 200; + response.status = 404; return; } @@ -855,9 +856,11 @@ void JFJochBrokerHttp::preview_plot_get(const std::optional &type, }; if (binning) { - if (binning.value() < 0) - throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, - "Binning must be positive number or zero"); + if (binning.value() < 0) { + response.status = 400; + response.set_content("Binning cannot be negative", "text/plain"); + return; + } req.binning = binning.value(); } diff --git a/broker/jfjoch_api.yaml b/broker/jfjoch_api.yaml index 67c0d2f1..4d1b2385 100644 --- a/broker/jfjoch_api.yaml +++ b/broker/jfjoch_api.yaml @@ -3163,6 +3163,8 @@ paths: responses: "200": description: All good + "400": + description: Mask is not 4-byte unsigned integer array or empty body "500": description: Error within Jungfraujoch code - see output message. content: @@ -3247,6 +3249,8 @@ paths: schema: type: string format: binary + "400": + description: Invalid gain level or storage cell number "404": description: No calibration recorded so far /preview/plot: diff --git a/broker/redoc-static.html b/broker/redoc-static.html index 9f99b400..5afd1ef4 100644 --- a/broker/redoc-static.html +++ b/broker/redoc-static.html @@ -818,6 +818,7 @@ Mask is expected as binary array (4-byte; unsigned). 0 - good pixel, other value - masked User mask is stored in NXmx pixel mask (bit 8), as well as used in spot finding and azimuthal integration.

Request Body schema: application/octet-stream
string <binary>

Responses

Response samples

Content type
application/json
{
  • "msg": "Detector in wrong state",
  • "reason": "WrongDAQState"
}

Get mask of the detector (TIFF)

Should be in Idle state. @@ -844,6 +845,7 @@ User mask is not automatically applied - i.e. pixels with user mask will have a

http://localhost:5232/config/user_mask.tiff

Response samples

Content type
application/json
{
  • "msg": "Detector in wrong state",
  • "reason": "WrongDAQState"
}

Get pedestal in TIFF format

query Parameters
gain_level
required
integer

Gain level (0, 1, 2)

sc
integer

Storage cell number

Responses

Generate 1D plot from Jungfraujoch

query Parameters
binning
integer
Default: 1

Binning of frames for the plot (0 = default binning)

@@ -913,7 +915,7 @@ then image might be replaced in the buffer between calling /images and /image.cb