Skip to content

Commit 831c08c

Browse files
authored
fix: ogx schemas (#1097)
- [ ] I added an entry to [`CHANGELOG.md`](CHANGELOG.md) if knowledge of this change could be valuable to users. --- Here is a brief summary of what I did: <TEXT>
2 parents 8c0dc0c + 40043c8 commit 831c08c

File tree

8 files changed

+85
-97
lines changed

8 files changed

+85
-97
lines changed

openapi.json

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,15 +4286,10 @@
42864286
{
42874287
"name": "request",
42884288
"in": "query",
4289-
"description": "type of WMS request",
4289+
"description": "type of WCS request",
42904290
"required": true,
42914291
"schema": {
4292-
"type": "string",
4293-
"enum": [
4294-
"GetCapabilGetCapabilitiesities",
4295-
"DescribeCoverage",
4296-
"GetCoverage"
4297-
]
4292+
"$ref": "#/components/schemas/WcsRequest"
42984293
}
42994294
},
43004295
{
@@ -4450,11 +4445,7 @@
44504445
"description": "type of WFS request",
44514446
"required": true,
44524447
"schema": {
4453-
"type": "string",
4454-
"enum": [
4455-
"GetCapabilities",
4456-
"GetFeature"
4457-
]
4448+
"$ref": "#/components/schemas/WfsRequest"
44584449
}
44594450
},
44604451
{
@@ -4732,7 +4723,7 @@
47324723
"type": "null"
47334724
},
47344725
{
4735-
"$ref": "#/components/schemas/GetCapabilitiesFormat"
4726+
"$ref": "#/components/schemas/WmsResponseFormat"
47364727
}
47374728
]
47384729
}
@@ -4790,14 +4781,7 @@
47904781
"description": "type of WMS request",
47914782
"required": true,
47924783
"schema": {
4793-
"type": "string",
4794-
"enum": [
4795-
"GetCapabilities",
4796-
"GetMap",
4797-
"GetFeatureInfo",
4798-
"GetStyles",
4799-
"GetLegendGraphic"
4800-
]
4784+
"$ref": "#/components/schemas/WmsRequest"
48014785
}
48024786
},
48034787
{
@@ -4888,14 +4872,7 @@
48884872
],
48894873
"responses": {
48904874
"200": {
4891-
"description": "OK",
4892-
"content": {
4893-
"text/xml": {
4894-
"schema": {
4895-
"type": "string"
4896-
}
4897-
}
4898-
}
4875+
"$ref": "#/components/responses/PngResponse"
48994876
}
49004877
},
49014878
"security": [
@@ -6935,37 +6912,19 @@
69356912
}
69366913
}
69376914
},
6938-
"GetCapabilitiesFormat": {
6939-
"type": "string",
6940-
"enum": [
6941-
"text/xml"
6942-
]
6943-
},
69446915
"GetCoverageFormat": {
69456916
"type": "string",
69466917
"enum": [
69476918
"image/tiff"
69486919
]
69496920
},
6950-
"GetFeatureRequest": {
6951-
"type": "string",
6952-
"enum": [
6953-
"GetFeature"
6954-
]
6955-
},
69566921
"GetMapExceptionFormat": {
69576922
"type": "string",
69586923
"enum": [
69596924
"XML",
69606925
"JSON"
69616926
]
69626927
},
6963-
"GetMapFormat": {
6964-
"type": "string",
6965-
"enum": [
6966-
"image/png"
6967-
]
6968-
},
69696928
"GfbioAbcdDataProviderDefinition": {
69706929
"type": "object",
69716930
"required": [
@@ -10830,6 +10789,14 @@
1083010789
}
1083110790
}
1083210791
},
10792+
"WcsRequest": {
10793+
"type": "string",
10794+
"enum": [
10795+
"GetCapabilities",
10796+
"DescribeCoverage",
10797+
"GetCoverage"
10798+
]
10799+
},
1083310800
"WcsService": {
1083410801
"type": "string",
1083510802
"enum": [
@@ -10843,6 +10810,13 @@
1084310810
"1.1.1"
1084410811
]
1084510812
},
10813+
"WfsRequest": {
10814+
"type": "string",
10815+
"enum": [
10816+
"GetCapabilities",
10817+
"GetFeature"
10818+
]
10819+
},
1084610820
"WfsService": {
1084710821
"type": "string",
1084810822
"enum": [
@@ -10911,6 +10885,23 @@
1091110885
}
1091210886
}
1091310887
},
10888+
"WmsRequest": {
10889+
"type": "string",
10890+
"enum": [
10891+
"GetCapabilities",
10892+
"GetMap",
10893+
"GetFeatureInfo",
10894+
"GetStyles",
10895+
"GetLegendGraphic"
10896+
]
10897+
},
10898+
"WmsResponseFormat": {
10899+
"type": "string",
10900+
"enum": [
10901+
"text/xml",
10902+
"image/png"
10903+
]
10904+
},
1091410905
"WmsService": {
1091510906
"type": "string",
1091610907
"enum": [

services/src/api/apidoc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,21 @@ use utoipa::{Modify, OpenApi};
331331
332332
OgcBoundingBox,
333333
334+
wcs::request::WcsRequest,
334335
wcs::request::WcsService,
335336
wcs::request::WcsVersion,
336337
wcs::request::GetCoverageFormat,
337338
wcs::request::WcsBoundingbox,
338339
340+
wms::request::WmsRequest,
339341
wms::request::WmsService,
340342
wms::request::WmsVersion,
341-
wms::request::GetCapabilitiesFormat,
342343
wms::request::GetMapExceptionFormat,
343-
wms::request::GetMapFormat,
344+
wms::request::WmsResponseFormat,
344345
346+
wfs::request::WfsRequest,
345347
wfs::request::WfsService,
346348
wfs::request::WfsVersion,
347-
wfs::request::GetFeatureRequest,
348349
wfs::request::TypeNames,
349350
350351
GeoJson,

services/src/api/handlers/wcs.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::time::Duration;
2929
use tracing::info;
3030
use url::Url;
3131
use utoipa::IntoParams;
32-
use utoipa::openapi::Required;
32+
use utoipa::openapi::{Ref, Required};
3333
use uuid::Uuid;
3434

3535
pub(crate) fn init_wcs_routes<C>(cfg: &mut web::ServiceConfig)
@@ -63,16 +63,8 @@ impl IntoParams for WcsQueryParams {
6363
.name("request")
6464
.required(utoipa::openapi::Required::True)
6565
.parameter_in(pip().unwrap_or_default())
66-
.description(Some("type of WMS request"))
67-
.schema(Some(
68-
utoipa::openapi::ObjectBuilder::new()
69-
.schema_type(utoipa::openapi::schema::Type::String)
70-
.enum_values(Some(vec![
71-
"GetCapabilGetCapabilitiesities",
72-
"DescribeCoverage",
73-
"GetCoverage",
74-
])),
75-
))
66+
.description(Some("type of WCS request"))
67+
.schema(Some(Ref::from_schema_name("WcsRequest")))
7668
.build(),
7769
);
7870

services/src/api/handlers/wfs.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use serde_json::json;
3636
use snafu::ensure;
3737
use std::str::FromStr;
3838
use std::time::Duration;
39-
use utoipa::openapi::Required;
39+
use utoipa::openapi::{Ref, Required};
4040
use utoipa::{IntoParams, ToSchema};
4141
use uuid::Uuid;
4242

@@ -72,11 +72,7 @@ impl IntoParams for WfsQueryParams {
7272
.required(utoipa::openapi::Required::True)
7373
.parameter_in(pip().unwrap_or_default())
7474
.description(Some("type of WFS request"))
75-
.schema(Some(
76-
utoipa::openapi::ObjectBuilder::new()
77-
.schema_type(utoipa::openapi::schema::Type::String)
78-
.enum_values(Some(vec!["GetCapabilities", "GetFeature"])),
79-
))
75+
.schema(Some(Ref::from_schema_name("WfsRequest")))
8076
.build(),
8177
);
8278

services/src/api/handlers/wms.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::str::FromStr;
3232
use std::time::Duration;
3333
use tracing::debug;
3434
use utoipa::IntoParams;
35-
use utoipa::openapi::Required;
35+
use utoipa::openapi::{Ref, Required};
3636
use uuid::Uuid;
3737

3838
pub(crate) fn init_wms_routes<C>(cfg: &mut web::ServiceConfig)
@@ -70,17 +70,7 @@ impl IntoParams for WmsQueryParams {
7070
.required(utoipa::openapi::Required::True)
7171
.parameter_in(pip().unwrap_or_default())
7272
.description(Some("type of WMS request"))
73-
.schema(Some(
74-
utoipa::openapi::ObjectBuilder::new()
75-
.schema_type(utoipa::openapi::schema::Type::String)
76-
.enum_values(Some(vec![
77-
"GetCapabilities",
78-
"GetMap",
79-
"GetFeatureInfo",
80-
"GetStyles",
81-
"GetLegendGraphic",
82-
])),
83-
))
73+
.schema(Some(Ref::from_schema_name("WmsRequest")))
8474
.build(),
8575
);
8676

@@ -172,7 +162,8 @@ impl IntoParams for WmsQueryParams {
172162
// </Layer>
173163
// </Capability>
174164
// </WMS_Capabilities>"#
175-
)
165+
),
166+
(status = 200, response = crate::api::model::responses::PngResponse),
176167
),
177168
params(
178169
("workflow" = WorkflowId, description = "Workflow id"),

services/src/api/ogc/wcs/request.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ use serde::de::Error;
1111
use serde::{Deserialize, Serialize};
1212
use utoipa::{IntoParams, ToSchema};
1313

14+
#[derive(Debug, Clone, Deserialize, ToSchema)]
15+
#[serde(rename_all = "PascalCase")]
16+
pub enum WcsRequest {
17+
GetCapabilities,
18+
DescribeCoverage,
19+
GetCoverage,
20+
}
21+
1422
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
1523
pub enum WcsService {
1624
#[serde(rename = "WCS")]

services/src/api/ogc/wfs/request.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ use utoipa::openapi::Type;
77
use utoipa::openapi::schema::{ObjectBuilder, SchemaType};
88
use utoipa::{IntoParams, PartialSchema, ToSchema};
99

10+
#[derive(Debug, Clone, Deserialize, ToSchema)]
11+
#[serde(rename_all = "PascalCase")]
12+
pub enum WfsRequest {
13+
GetCapabilities,
14+
GetFeature,
15+
}
16+
1017
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
1118
pub enum WfsService {
1219
#[serde(rename = "WFS")]
@@ -76,11 +83,6 @@ pub struct GetFeature {
7683
// TODO: feature_id, ...
7784
}
7885

79-
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
80-
pub enum GetFeatureRequest {
81-
GetFeature,
82-
}
83-
8486
#[allow(clippy::option_if_let_else)]
8587
pub fn parse_type_names<'de, D>(deserializer: D) -> Result<TypeNames, D::Error>
8688
where

services/src/api/ogc/wms/request.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ use crate::util::{bool_option_case_insensitive, from_str};
44
use serde::{Deserialize, Serialize};
55
use utoipa::{IntoParams, ToSchema};
66

7+
#[derive(Debug, Clone, Deserialize, ToSchema)]
8+
#[serde(rename_all = "PascalCase")]
9+
#[allow(clippy::enum_variant_names)]
10+
pub enum WmsRequest {
11+
GetCapabilities,
12+
GetMap,
13+
GetFeatureInfo,
14+
GetStyles,
15+
GetLegendGraphic,
16+
}
17+
718
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
819
pub enum WmsService {
920
#[serde(rename = "WMS")]
@@ -23,13 +34,15 @@ pub struct GetCapabilities {
2334
#[serde(alias = "SERVICE")]
2435
pub service: WmsService,
2536
#[serde(alias = "FORMAT")]
26-
pub format: Option<GetCapabilitiesFormat>,
37+
pub format: Option<WmsResponseFormat>,
2738
}
2839

2940
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
30-
pub enum GetCapabilitiesFormat {
41+
pub enum WmsResponseFormat {
3142
#[serde(rename = "text/xml")]
32-
TextXml, // TODO: remaining formats
43+
TextXml,
44+
#[serde(rename = "image/png")]
45+
ImagePng, // TODO: remaining formats
3346
}
3447

3548
// TODO: remove serde aliases and use serde-aux and case insensitive keys
@@ -52,7 +65,7 @@ pub struct GetMap {
5265
#[param(example = "-90,-180,90,180")]
5366
pub bbox: OgcBoundingBox,
5467
#[serde(alias = "FORMAT")]
55-
pub format: GetMapFormat,
68+
pub format: WmsResponseFormat,
5669
#[serde(alias = "LAYERS")]
5770
#[param(example = "<Workflow Id>")]
5871
pub layers: String,
@@ -94,12 +107,6 @@ pub enum GetMapExceptionFormat {
94107
Json, // UNSUPPORTED: INIMAGE, BLANK
95108
}
96109

97-
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, ToSchema)]
98-
pub enum GetMapFormat {
99-
#[serde(rename = "image/png")]
100-
ImagePng, // TODO: remaining formats
101-
}
102-
103110
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, IntoParams)]
104111
pub struct GetFeatureInfo {
105112
pub version: String,
@@ -161,7 +168,7 @@ mod tests {
161168
elevation: Some("elevation".into()),
162169
bbox: OgcBoundingBox::new(1., 2., 3., 4.),
163170
height: 2,
164-
format: GetMapFormat::ImagePng,
171+
format: WmsResponseFormat::ImagePng,
165172
exceptions: Some(GetMapExceptionFormat::Json),
166173
};
167174

@@ -188,7 +195,7 @@ mod tests {
188195
elevation: None,
189196
bbox: OgcBoundingBox::new(1., 2., 3., 4.),
190197
height: 2,
191-
format: GetMapFormat::ImagePng,
198+
format: WmsResponseFormat::ImagePng,
192199
exceptions: None,
193200
};
194201

0 commit comments

Comments
 (0)