openapi: fix query parameters (fix #1160)

This commit is contained in:
Alex Auvolat
2025-09-14 17:25:04 +02:00
parent 3148fa3afe
commit 7a256b2ebb
3 changed files with 62 additions and 73 deletions
+19 -17
View File
@@ -31,7 +31,7 @@
"parameters": [ "parameters": [
{ {
"name": "domain", "name": "domain",
"in": "path", "in": "query",
"description": "The domain name to check for", "description": "The domain name to check for",
"required": true, "required": true,
"schema": { "schema": {
@@ -408,7 +408,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -443,7 +443,7 @@
"parameters": [ "parameters": [
{ {
"name": "id", "name": "id",
"in": "path", "in": "query",
"description": "Admin API token ID", "description": "Admin API token ID",
"required": true, "required": true,
"schema": { "schema": {
@@ -472,6 +472,7 @@
{ {
"name": "id", "name": "id",
"in": "query", "in": "query",
"description": "ID of the bucket to delete",
"required": true, "required": true,
"schema": { "schema": {
"type": "string" "type": "string"
@@ -504,7 +505,7 @@
"parameters": [ "parameters": [
{ {
"name": "id", "name": "id",
"in": "path", "in": "query",
"description": "Access key ID", "description": "Access key ID",
"required": true, "required": true,
"schema": { "schema": {
@@ -610,7 +611,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -902,7 +903,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -937,7 +938,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -972,7 +973,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1017,7 +1018,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1141,7 +1142,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1210,7 +1211,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1293,7 +1294,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1362,7 +1363,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1441,7 +1442,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1510,7 +1511,7 @@
"parameters": [ "parameters": [
{ {
"name": "node", "name": "node",
"in": "path", "in": "query",
"description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request", "description": "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request",
"required": true, "required": true,
"schema": { "schema": {
@@ -1555,7 +1556,7 @@
"parameters": [ "parameters": [
{ {
"name": "id", "name": "id",
"in": "path", "in": "query",
"description": "Admin API token ID", "description": "Admin API token ID",
"required": true, "required": true,
"schema": { "schema": {
@@ -1601,6 +1602,7 @@
{ {
"name": "id", "name": "id",
"in": "query", "in": "query",
"description": "ID of the bucket to update",
"required": true, "required": true,
"schema": { "schema": {
"type": "string" "type": "string"
@@ -1682,7 +1684,7 @@
"parameters": [ "parameters": [
{ {
"name": "id", "name": "id",
"in": "path", "in": "query",
"description": "Access key ID", "description": "Access key ID",
"required": true, "required": true,
"schema": { "schema": {
+26 -5
View File
@@ -145,6 +145,13 @@ pub struct MultiResponse<RB> {
pub error: HashMap<String, String>, pub error: HashMap<String, String>,
} }
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct MultiRequestQueryParams {
/// Node ID to query, or `*` for all nodes, or `self` for the node responding to the request
pub node: String,
}
// ********************************************** // **********************************************
// Special endpoints // Special endpoints
// //
@@ -155,8 +162,10 @@ pub struct MultiResponse<RB> {
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OptionsRequest; pub struct OptionsRequest;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct CheckDomainRequest { pub struct CheckDomainRequest {
/// The domain name to check for
pub domain: String, pub domain: String,
} }
@@ -355,9 +364,12 @@ pub struct CreateAdminTokenResponse {
// ---- UpdateAdminToken ---- // ---- UpdateAdminToken ----
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct UpdateAdminTokenRequest { pub struct UpdateAdminTokenRequest {
/// Admin API token ID
pub id: String, pub id: String,
#[param(ignore = true)]
pub body: UpdateAdminTokenRequestBody, pub body: UpdateAdminTokenRequestBody,
} }
@@ -384,8 +396,10 @@ pub struct UpdateAdminTokenResponse(pub GetAdminTokenInfoResponse);
// ---- DeleteAdminToken ---- // ---- DeleteAdminToken ----
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct DeleteAdminTokenRequest { pub struct DeleteAdminTokenRequest {
/// Admin API token ID
pub id: String, pub id: String,
} }
@@ -736,9 +750,12 @@ pub struct ImportKeyResponse(pub GetKeyInfoResponse);
// ---- UpdateKey ---- // ---- UpdateKey ----
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct UpdateKeyRequest { pub struct UpdateKeyRequest {
/// Access key ID
pub id: String, pub id: String,
#[param(ignore = true)]
pub body: UpdateKeyRequestBody, pub body: UpdateKeyRequestBody,
} }
@@ -763,8 +780,10 @@ pub struct UpdateKeyRequestBody {
// ---- DeleteKey ---- // ---- DeleteKey ----
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)]
pub struct DeleteKeyRequest { pub struct DeleteKeyRequest {
/// Access key ID
pub id: String, pub id: String,
} }
@@ -894,6 +913,7 @@ pub struct CreateBucketLocalAlias {
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)] #[into_params(parameter_in = Query)]
pub struct UpdateBucketRequest { pub struct UpdateBucketRequest {
/// ID of the bucket to update
pub id: String, pub id: String,
#[param(ignore = true)] #[param(ignore = true)]
pub body: UpdateBucketRequestBody, pub body: UpdateBucketRequestBody,
@@ -922,6 +942,7 @@ pub struct UpdateBucketWebsiteAccess {
#[derive(Debug, Clone, Serialize, Deserialize, IntoParams)] #[derive(Debug, Clone, Serialize, Deserialize, IntoParams)]
#[into_params(parameter_in = Query)] #[into_params(parameter_in = Query)]
pub struct DeleteBucketRequest { pub struct DeleteBucketRequest {
/// ID of the bucket to delete
pub id: String, pub id: String,
} }
+17 -51
View File
@@ -46,9 +46,7 @@ a static website for the requested domain. This is used by reverse proxies such
as Caddy or Tricot, to avoid requesting TLS certificates for domain names that as Caddy or Tricot, to avoid requesting TLS certificates for domain names that
do not correspond to an actual website. do not correspond to an actual website.
", ",
params( params(CheckDomainRequest),
("domain" = String, description = "The domain name to check for"),
),
security(()), security(()),
responses( responses(
(status = 200, description = "The domain name redirects to a static website bucket"), (status = 200, description = "The domain name redirects to a static website bucket"),
@@ -167,9 +165,7 @@ fn CreateAdminToken() -> () {}
Updates information about the specified admin API token. Updates information about the specified admin API token.
", ",
request_body = UpdateAdminTokenRequestBody, request_body = UpdateAdminTokenRequestBody,
params( params(UpdateAdminTokenRequest),
("id" = String, description = "Admin API token ID"),
),
responses( responses(
(status = 200, description = "Admin token has been updated", body = UpdateAdminTokenResponse), (status = 200, description = "Admin token has been updated", body = UpdateAdminTokenResponse),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -181,9 +177,7 @@ fn UpdateAdminToken() -> () {}
path = "/v2/DeleteAdminToken", path = "/v2/DeleteAdminToken",
tag = "Admin API token", tag = "Admin API token",
description = "Delete an admin API token from the cluster, revoking all its permissions.", description = "Delete an admin API token from the cluster, revoking all its permissions.",
params( params(DeleteAdminTokenRequest),
("id" = String, description = "Admin API token ID"),
),
responses( responses(
(status = 200, description = "Admin token has been deleted"), (status = 200, description = "Admin token has been deleted"),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -391,9 +385,7 @@ Updates information about the specified API access key.
*Note: the secret key is not returned in the response, `null` is sent instead.* *Note: the secret key is not returned in the response, `null` is sent instead.*
", ",
request_body = UpdateKeyRequestBody, request_body = UpdateKeyRequestBody,
params( params(UpdateKeyRequest),
("id" = String, description = "Access key ID"),
),
responses( responses(
(status = 200, description = "Access key has been updated", body = UpdateKeyResponse), (status = 200, description = "Access key has been updated", body = UpdateKeyResponse),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -405,9 +397,7 @@ fn UpdateKey() -> () {}
path = "/v2/DeleteKey", path = "/v2/DeleteKey",
tag = "Access key", tag = "Access key",
description = "Delete a key from the cluster. Its access will be removed from all the buckets. Buckets are not automatically deleted and can be dangling. You should manually delete them before. ", description = "Delete a key from the cluster. Its access will be removed from all the buckets. Buckets are not automatically deleted and can be dangling. You should manually delete them before. ",
params( params(DeleteKeyRequest),
("id" = String, description = "Access key ID"),
),
responses( responses(
(status = 200, description = "Access key has been deleted"), (status = 200, description = "Access key has been deleted"),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -626,9 +616,7 @@ fn RemoveBucketAlias() -> () {}
description = " description = "
Return information about the Garage daemon running on one or several nodes. Return information about the Garage daemon running on one or several nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetNodeInfoResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetNodeInfoResponse>),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -644,9 +632,7 @@ Fetch statistics for one or several Garage nodes.
*Note: do not try to parse the `freeform` field of the response, it is given as a string specifically because its format is not stable.* *Note: do not try to parse the `freeform` field of the response, it is given as a string specifically because its format is not stable.*
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetNodeStatisticsResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetNodeStatisticsResponse>),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -660,9 +646,7 @@ fn GetNodeStatistics() -> () {}
description = " description = "
Instruct one or several nodes to take a snapshot of their metadata databases. Instruct one or several nodes to take a snapshot of their metadata databases.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalCreateMetadataSnapshotResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalCreateMetadataSnapshotResponse>),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -676,9 +660,7 @@ fn CreateMetadataSnapshot() -> () {}
description = " description = "
Launch a repair operation on one or several cluster nodes. Launch a repair operation on one or several cluster nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalLaunchRepairOperationRequest, request_body = LocalLaunchRepairOperationRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalLaunchRepairOperationResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalLaunchRepairOperationResponse>),
@@ -697,9 +679,7 @@ fn LaunchRepairOperation() -> () {}
description = " description = "
List background workers currently running on one or several cluster nodes. List background workers currently running on one or several cluster nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalListWorkersRequest, request_body = LocalListWorkersRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalListWorkersResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalListWorkersResponse>),
@@ -714,9 +694,7 @@ fn ListWorkers() -> () {}
description = " description = "
Get information about the specified background worker on one or several cluster nodes. Get information about the specified background worker on one or several cluster nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalGetWorkerInfoRequest, request_body = LocalGetWorkerInfoRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetWorkerInfoResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetWorkerInfoResponse>),
@@ -731,9 +709,7 @@ fn GetWorkerInfo() -> () {}
description = " description = "
Fetch values of one or several worker variables, from one or several cluster nodes. Fetch values of one or several worker variables, from one or several cluster nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalGetWorkerVariableRequest, request_body = LocalGetWorkerVariableRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetWorkerVariableResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalGetWorkerVariableResponse>),
@@ -748,9 +724,7 @@ fn GetWorkerVariable() -> () {}
description = " description = "
Set the value for a worker variable, on one or several cluster nodes. Set the value for a worker variable, on one or several cluster nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalSetWorkerVariableRequest, request_body = LocalSetWorkerVariableRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalSetWorkerVariableResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalSetWorkerVariableResponse>),
@@ -769,9 +743,7 @@ fn SetWorkerVariable() -> () {}
description = " description = "
List data blocks that are currently in an errored state on one or several Garage nodes. List data blocks that are currently in an errored state on one or several Garage nodes.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalListBlockErrorsResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalListBlockErrorsResponse>),
(status = 500, description = "Internal server error") (status = 500, description = "Internal server error")
@@ -785,9 +757,7 @@ fn ListBlockErrors() -> () {}
description = " description = "
Get detailed information about a data block stored on a Garage node, including all object versions and in-progress multipart uploads that contain a reference to this block. Get detailed information about a data block stored on a Garage node, including all object versions and in-progress multipart uploads that contain a reference to this block.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalGetBlockInfoRequest, request_body = LocalGetBlockInfoRequest,
responses( responses(
(status = 200, description = "Detailed block information", body = MultiResponse<LocalGetBlockInfoResponse>), (status = 200, description = "Detailed block information", body = MultiResponse<LocalGetBlockInfoResponse>),
@@ -802,9 +772,7 @@ fn GetBlockInfo() -> () {}
description = " description = "
Instruct Garage node(s) to retry the resynchronization of one or several missing data block(s). Instruct Garage node(s) to retry the resynchronization of one or several missing data block(s).
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalRetryBlockResyncRequest, request_body = LocalRetryBlockResyncRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalRetryBlockResyncResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalRetryBlockResyncResponse>),
@@ -821,9 +789,7 @@ Purge references to one or several missing data blocks.
This will remove all objects and in-progress multipart uploads that contain the specified data block(s). The objects will be permanently deleted from the buckets in which they appear. Use with caution. This will remove all objects and in-progress multipart uploads that contain the specified data block(s). The objects will be permanently deleted from the buckets in which they appear. Use with caution.
", ",
params( params(MultiRequestQueryParams),
("node" = String, description = "Node ID to query, or `*` for all nodes, or `self` for the node responding to the request"),
),
request_body = LocalPurgeBlocksRequest, request_body = LocalPurgeBlocksRequest,
responses( responses(
(status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalPurgeBlocksResponse>), (status = 200, description = "Responses from individual cluster nodes", body = MultiResponse<LocalPurgeBlocksResponse>),