Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ogcapi-services/src/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl IntoResponseParts for LocationHeader {
impl IntoResponse for ProcessResultsResponse {
fn into_response(self) -> Response {
if let ogcapi_types::processes::Response::Document = self.response_mode {
let results = ogcapi_types::processes::Results {
let results = ogcapi_types::processes::Results::Json {
results: self
.results
.into_iter()
Expand Down
3 changes: 2 additions & 1 deletion ogcapi-services/src/routes/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ fn negotiate_execution_mode(
///
/// For more information, see [Section 11](https://docs.ogc.org/is/18-062/18-062.html#sc_job_list).
#[utoipa::path(get, path = "/jobs", tag = "Processes",
params(LimitOffsetPagination),
responses(
(
status = 200,
Expand All @@ -411,7 +412,7 @@ async fn jobs(
const MAX_LIMIT: usize = 100;

let offset = query.offset.unwrap_or_default();
let limit = query.limit.unwrap_or(DEFAULT_LIMIT).max(MAX_LIMIT);
let limit = query.limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT);

let jobs = state.drivers.jobs.status_list(offset, limit).await?;

Expand Down
4 changes: 2 additions & 2 deletions ogcapi-types/src/common/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use serde_with::DisplayFromStr;
use utoipa::ToSchema;
use utoipa::{IntoParams, ToSchema};

use crate::common::{Bbox, Crs, Datetime};

Expand All @@ -24,7 +24,7 @@ pub struct Query {
}

/// Query parameters to facilitate pagination with a limit and offset
#[derive(Serialize, Deserialize, ToSchema, Debug, Clone, PartialEq, Eq, Default)]
#[derive(Serialize, Deserialize, ToSchema, Debug, Clone, PartialEq, Eq, Default, IntoParams)]
pub struct LimitOffsetPagination {
/// Amount of items to return
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down
23 changes: 11 additions & 12 deletions ogcapi-types/src/processes/job.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, ops::Deref};
use std::{collections::HashMap, marker::PhantomData};

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -79,15 +79,14 @@ pub struct ResultsQuery {
}

#[derive(Serialize, Deserialize, ToSchema, Debug, Clone)]
pub struct Results {
#[serde(flatten)]
pub results: HashMap<String, InlineOrRefData>,
}

impl Deref for Results {
type Target = HashMap<String, InlineOrRefData>;

fn deref(&self) -> &Self::Target {
&self.results
}
#[serde(untagged)]
#[schema(title = "ExecuteResults")]
pub enum Results {
Json {
#[serde(flatten)]
results: HashMap<String, InlineOrRefData>,
},
#[schema(value_type = String, format = Binary)]
// The `PhantomData` marker is required for proper OpenApi schema generation.
Binary(PhantomData<Vec<u8>>),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this wrapped in 'PhantomData'?

Copy link
Copy Markdown
Contributor Author

@ChristianBeilschmidt ChristianBeilschmidt Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Results type is more or less used for the API specs. The logic for serializing binary data cannot be behind a serde enum variant. As such, we indicate a type and do the rest with #[schema].

Having an actual Vec<u8> would result in utoipa to incorrectly say it is a list of int or something.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I would expect value_type to be here for that exactly. Maybe this is a shortcoming of utoipa. Maybe a comment would be reasonable here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, cf. juhaku/utoipa#1146

}
Loading