diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index c93e80e45..137e30782 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -35,6 +35,5 @@ jobs: - run: | git config user.email "github@3box.io" git config user.name "Github Automation" - - run: npm install @openapitools/openapi-generator-cli@2.6.0 -g - name: Create release PR run: make RELEASE_LEVEL=${{ github.event.inputs.level }} release-pr diff --git a/.github/workflows/rust-build-and-test.yml b/.github/workflows/rust-build-and-test.yml index a3f644543..576014034 100644 --- a/.github/workflows/rust-build-and-test.yml +++ b/.github/workflows/rust-build-and-test.yml @@ -44,7 +44,6 @@ jobs: run: make check-clippy - name: Check generated servers run: | - npm install @openapitools/openapi-generator-cli@2.6.0 -g make check-api-server make check-kubo-rpc-server test: diff --git a/.gitignore b/.gitignore index 65530433f..aa96494ac 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ peer* sync_test.sh + +openapi-generator-cli.jar diff --git a/Cargo.lock b/Cargo.lock index 850b1b20b..d30226c6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,6 +1117,7 @@ dependencies = [ "tokio", "tokio-openssl", "url", + "validator", ] [[package]] @@ -1241,6 +1242,7 @@ dependencies = [ "tokio", "tokio-openssl", "url", + "validator", ] [[package]] @@ -3604,6 +3606,12 @@ dependencies = [ "windows", ] +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + [[package]] name = "igd-next" version = "0.14.2" @@ -9483,6 +9491,48 @@ dependencies = [ "serde", ] +[[package]] +name = "validator" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b92f40481c04ff1f4f61f304d61793c7b56ff76ac1469f1beb199b1445b253bd" +dependencies = [ + "idna", + "lazy_static", + "regex", + "serde", + "serde_derive", + "serde_json", + "url", + "validator_derive", +] + +[[package]] +name = "validator_derive" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc44ca3088bb3ba384d9aecf40c6a23a676ce23e09bdaca2073d99c207f864af" +dependencies = [ + "if_chain", + "lazy_static", + "proc-macro-error", + "proc-macro2 1.0.76", + "quote 1.0.35", + "regex", + "syn 1.0.109", + "validator_types", +] + +[[package]] +name = "validator_types" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111abfe30072511849c5910134e8baf8dc05de4c0e5903d681cbd5c9c4d611e3" +dependencies = [ + "proc-macro2 1.0.76", + "syn 1.0.109", +] + [[package]] name = "valuable" version = "0.1.0" diff --git a/Makefile b/Makefile index 0252a1d90..5e6aa0898 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Therefore may be useful in ensuring a change # is ready to pass CI checks. -RUSTFLAGS = --cfg tokio_unstable +RUSTFLAGS = -D warnings --cfg tokio_unstable CARGO = RUSTFLAGS='${RUSTFLAGS}' cargo RELEASE_LEVEL ?= minor @@ -55,7 +55,6 @@ check-kubo-rpc-server: ./ci-scripts/check_kubo_rpc_server.sh .PHONY: release -release: RUSTFLAGS += -D warnings release: $(CARGO) build -p ceramic-one --locked --release diff --git a/api-server/.openapi-generator/VERSION b/api-server/.openapi-generator/VERSION index cd802a1ec..4b49d9bb6 100644 --- a/api-server/.openapi-generator/VERSION +++ b/api-server/.openapi-generator/VERSION @@ -1 +1 @@ -6.6.0 \ No newline at end of file +7.2.0 \ No newline at end of file diff --git a/api-server/Cargo.toml b/api-server/Cargo.toml index a7339327f..815cc7ea2 100644 --- a/api-server/Cargo.toml +++ b/api-server/Cargo.toml @@ -35,6 +35,7 @@ mime = "0.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +validator = { version = "0.16", features = ["derive"] } # Crates included if required by the API definition diff --git a/api-server/README.md b/api-server/README.md index e0bd0f50b..704b722d3 100644 --- a/api-server/README.md +++ b/api-server/README.md @@ -15,7 +15,7 @@ To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.9.0 -- Build date: 2024-01-17T12:46:40.618372865-07:00[America/Denver] +- Build date: 2024-01-24T14:39:40.257161505-07:00[America/Denver] diff --git a/api-server/examples/server/server.rs b/api-server/examples/server/server.rs index 9378df25a..8918b4772 100644 --- a/api-server/examples/server/server.rs +++ b/api-server/examples/server/server.rs @@ -118,7 +118,6 @@ where event: models::Event, context: &C, ) -> Result { - let context = context.clone(); info!( "events_post({:?}) - X-Span-ID: {:?}", event, @@ -129,7 +128,6 @@ where /// Test the liveness of the Ceramic node async fn liveness_get(&self, context: &C) -> Result { - let context = context.clone(); info!("liveness_get() - X-Span-ID: {:?}", context.get().0.clone()); Err(ApiError("Generic failure".into())) } @@ -145,14 +143,12 @@ where limit: Option, context: &C, ) -> Result { - let context = context.clone(); info!("subscribe_sort_key_sort_value_get(\"{}\", \"{}\", {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", sort_key, sort_value, controller, stream_id, offset, limit, context.get().0.clone()); Err(ApiError("Generic failure".into())) } /// Get the version of the Ceramic node async fn version_post(&self, context: &C) -> Result { - let context = context.clone(); info!("version_post() - X-Span-ID: {:?}", context.get().0.clone()); Err(ApiError("Generic failure".into())) } diff --git a/api-server/src/models.rs b/api-server/src/models.rs index f18d3419d..90af15542 100644 --- a/api-server/src/models.rs +++ b/api-server/src/models.rs @@ -1,12 +1,14 @@ #![allow(clippy::useless_vec)] #![allow(unused_qualifications)] +use validator::Validate; + #[cfg(any(feature = "client", feature = "server"))] use crate::header; use crate::models; /// A Ceramic event as part of a Ceramic Stream -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Event { /// Multibase encoding of event id bytes. @@ -158,7 +160,7 @@ impl std::convert::TryFrom for header::IntoHeaderVal } /// Version of the Ceramic node in semver format, e.g. 2.1.0 -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Version { /// Version of the Ceramic node @@ -182,7 +184,7 @@ impl std::string::ToString for Version { let params: Vec> = vec![self .version .as_ref() - .map(|version| vec!["version".to_string(), version.to_string()].join(","))]; + .map(|version| ["version".to_string(), version.to_string()].join(","))]; params.into_iter().flatten().collect::>().join(",") } diff --git a/api-server/src/server/mod.rs b/api-server/src/server/mod.rs index 7da330f56..959c026aa 100644 --- a/api-server/src/server/mod.rs +++ b/api-server/src/server/mod.rs @@ -420,9 +420,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for SUBSCRIBE_SORT_KEY_SORT_VALUE_GET_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -461,9 +461,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for VERSION_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { diff --git a/ci-scripts/gen_api_server.sh b/ci-scripts/gen_api_server.sh index 34e6d5a07..8a007f0dc 100755 --- a/ci-scripts/gen_api_server.sh +++ b/ci-scripts/gen_api_server.sh @@ -6,7 +6,7 @@ cd $DIR/.. # Generate crate -npx @openapitools/openapi-generator-cli \ +./ci-scripts/openapi-generator-cli.sh \ generate \ -i api/ceramic.yaml \ -g rust-server \ diff --git a/ci-scripts/gen_kubo_rpc_server.sh b/ci-scripts/gen_kubo_rpc_server.sh index 3c54cbf79..7c7c89da4 100755 --- a/ci-scripts/gen_kubo_rpc_server.sh +++ b/ci-scripts/gen_kubo_rpc_server.sh @@ -8,7 +8,7 @@ cd $DIR/.. # Generate crate -npx @openapitools/openapi-generator-cli \ +./ci-scripts/openapi-generator-cli.sh \ generate \ -i kubo-rpc/kubo-rpc.yaml \ -g rust-server \ diff --git a/ci-scripts/openapi-generator-cli.sh b/ci-scripts/openapi-generator-cli.sh new file mode 100755 index 000000000..7f73aef42 --- /dev/null +++ b/ci-scripts/openapi-generator-cli.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# This script is a small wrapper to download the jar file for openapi-generator-cli and run it. + +VERSION='7.2.0' +jar=openapi-generator-cli.jar + +if [ ! -f $jar ] +then + wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${VERSION}/openapi-generator-cli-${VERSION}.jar -O $jar +fi + +java -ea \ + -Xms512M \ + -Xmx1024M \ + -server \ + -jar ./${jar} "$@" diff --git a/kubo-rpc-server/.openapi-generator/VERSION b/kubo-rpc-server/.openapi-generator/VERSION index cd802a1ec..4b49d9bb6 100644 --- a/kubo-rpc-server/.openapi-generator/VERSION +++ b/kubo-rpc-server/.openapi-generator/VERSION @@ -1 +1 @@ -6.6.0 \ No newline at end of file +7.2.0 \ No newline at end of file diff --git a/kubo-rpc-server/Cargo.toml b/kubo-rpc-server/Cargo.toml index c50bffdfe..95bb155ac 100644 --- a/kubo-rpc-server/Cargo.toml +++ b/kubo-rpc-server/Cargo.toml @@ -39,6 +39,7 @@ mime = "0.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +validator = { version = "0.16", features = ["derive"] } # Crates included if required by the API definition mime_0_2 = { package = "mime", version = "0.2.6", optional = true } diff --git a/kubo-rpc-server/README.md b/kubo-rpc-server/README.md index c7317d074..ad9192977 100644 --- a/kubo-rpc-server/README.md +++ b/kubo-rpc-server/README.md @@ -15,7 +15,7 @@ To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.9.0 -- Build date: 2024-01-17T12:46:50.987533413-07:00[America/Denver] +- Build date: 2024-01-24T14:39:45.959361295-07:00[America/Denver] diff --git a/kubo-rpc-server/examples/server/server.rs b/kubo-rpc-server/examples/server/server.rs index f7504cf01..05d73037f 100644 --- a/kubo-rpc-server/examples/server/server.rs +++ b/kubo-rpc-server/examples/server/server.rs @@ -122,7 +122,6 @@ where offline: Option, context: &C, ) -> Result { - let context = context.clone(); info!( "block_get_post(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", arg, @@ -142,7 +141,6 @@ where pin: Option, context: &C, ) -> Result { - let context = context.clone(); info!( "block_put_post({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", file, @@ -160,7 +158,6 @@ where arg: String, context: &C, ) -> Result { - let context = context.clone(); info!( "block_stat_post(\"{}\") - X-Span-ID: {:?}", arg, @@ -176,7 +173,6 @@ where output_codec: Option, context: &C, ) -> Result { - let context = context.clone(); info!( "dag_get_post(\"{}\", {:?}) - X-Span-ID: {:?}", arg, @@ -192,7 +188,6 @@ where file: swagger::ByteArray, context: &C, ) -> Result { - let context = context.clone(); info!( "dag_import_post({:?}) - X-Span-ID: {:?}", file, @@ -209,7 +204,6 @@ where input_codec: Option, context: &C, ) -> Result { - let context = context.clone(); info!( "dag_put_post({:?}, {:?}, {:?}) - X-Span-ID: {:?}", file, @@ -226,7 +220,6 @@ where arg: String, context: &C, ) -> Result { - let context = context.clone(); info!( "dag_resolve_post(\"{}\") - X-Span-ID: {:?}", arg, @@ -237,7 +230,6 @@ where /// Report identifying information about a node async fn id_post(&self, arg: Option, context: &C) -> Result { - let context = context.clone(); info!( "id_post({:?}) - X-Span-ID: {:?}", arg, @@ -254,7 +246,6 @@ where progress: Option, context: &C, ) -> Result { - let context = context.clone(); info!( "pin_add_post(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}", arg, @@ -267,7 +258,6 @@ where /// Remove a block from the pin store async fn pin_rm_post(&self, arg: String, context: &C) -> Result { - let context = context.clone(); info!( "pin_rm_post(\"{}\") - X-Span-ID: {:?}", arg, @@ -282,7 +272,6 @@ where arg: &Vec, context: &C, ) -> Result { - let context = context.clone(); info!( "swarm_connect_post({:?}) - X-Span-ID: {:?}", arg, @@ -293,7 +282,6 @@ where /// Report connected peers async fn swarm_peers_post(&self, context: &C) -> Result { - let context = context.clone(); info!( "swarm_peers_post() - X-Span-ID: {:?}", context.get().0.clone() @@ -303,7 +291,6 @@ where /// Report server version async fn version_post(&self, context: &C) -> Result { - let context = context.clone(); info!("version_post() - X-Span-ID: {:?}", context.get().0.clone()); Err(ApiError("Generic failure".into())) } diff --git a/kubo-rpc-server/src/models.rs b/kubo-rpc-server/src/models.rs index 4235e7d44..3e9f80248 100644 --- a/kubo-rpc-server/src/models.rs +++ b/kubo-rpc-server/src/models.rs @@ -1,10 +1,12 @@ #![allow(unused_qualifications)] +use validator::Validate; + #[cfg(any(feature = "client", feature = "server"))] use crate::header; use crate::models; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct BlockPutPost200Response { #[serde(rename = "Key")] @@ -201,7 +203,7 @@ impl std::str::FromStr for Codecs { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DagImportPost200Response { #[serde(rename = "Root")] @@ -339,7 +341,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DagPutPost200Response { #[serde(rename = "Cid")] @@ -477,7 +479,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DagPutPost200ResponseCid { #[serde(rename = "/")] @@ -611,7 +613,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DagResolvePost200Response { #[serde(rename = "Cid")] @@ -768,7 +770,7 @@ impl std::convert::TryFrom } /// root cid -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DagResolvePost200ResponseCid { /// root cid @@ -899,7 +901,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Error { #[serde(rename = "Message")] @@ -1064,7 +1066,7 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct IdPost200Response { #[serde(rename = "ID")] @@ -1318,7 +1320,7 @@ impl std::str::FromStr for Multihash { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct PinAddPost200Response { #[serde(rename = "Pins")] @@ -1454,7 +1456,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct SwarmConnectPost200Response { #[serde(rename = "Strings")] @@ -1590,7 +1592,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct SwarmPeersPost200Response { #[serde(rename = "Peers")] @@ -1722,7 +1724,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct SwarmPeersPost200ResponsePeersInner { #[serde(rename = "Addr")] @@ -1871,7 +1873,7 @@ impl std::convert::TryFrom } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct VersionPost200Response { #[serde(rename = "Commit")] diff --git a/kubo-rpc-server/src/server/mod.rs b/kubo-rpc-server/src/server/mod.rs index 75f47d9b6..b48073ea0 100644 --- a/kubo-rpc-server/src/server/mod.rs +++ b/kubo-rpc-server/src/server/mod.rs @@ -271,8 +271,8 @@ where CONTENT_TYPE, HeaderValue::from_str("text/plain") .expect("Unable to create Content-Type header for BLOCK_GET_POST_SUCCESS")); - let body = body.0; - *response.body_mut() = Body::from(body); + let body_content = body.0; + *response.body_mut() = Body::from(body_content); } BlockGetPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -281,9 +281,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_GET_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } BlockGetPostResponse::InternalError(body) => { *response.status_mut() = StatusCode::from_u16(500) @@ -292,9 +292,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_GET_POST_INTERNAL_ERROR")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -441,8 +441,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_PUT_POST_SUCCESS")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, BlockPutPostResponse::BadRequest (body) @@ -452,8 +452,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_PUT_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, }, Err(_) => { @@ -528,9 +528,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_STAT_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } BlockStatPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -539,9 +539,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for BLOCK_STAT_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -633,8 +633,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/octet-stream") .expect("Unable to create Content-Type header for DAG_GET_POST_SUCCESS")); - let body = body.0; - *response.body_mut() = Body::from(body); + let body_content = body.0; + *response.body_mut() = Body::from(body_content); } DagGetPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -643,9 +643,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_GET_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -728,8 +728,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_IMPORT_POST_SUCCESS")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, DagImportPostResponse::BadRequest (body) @@ -739,8 +739,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_IMPORT_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, }, Err(_) => { @@ -874,8 +874,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_PUT_POST_SUCCESS")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, DagPutPostResponse::BadRequest (body) @@ -885,8 +885,8 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_PUT_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + let body_content = serde_json::to_string(&body).expect("impossible to fail to serialize"); + *response.body_mut() = Body::from(body_content); }, }, Err(_) => { @@ -961,9 +961,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_RESOLVE_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } DagResolvePostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -972,9 +972,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for DAG_RESOLVE_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -1037,9 +1037,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for ID_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } IdPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1048,9 +1048,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for ID_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } } } @@ -1160,9 +1160,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for PIN_ADD_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } PinAddPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1171,9 +1171,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for PIN_ADD_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -1242,9 +1242,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for PIN_RM_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } PinRmPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1253,9 +1253,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for PIN_RM_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -1307,9 +1307,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for SWARM_CONNECT_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } SwarmConnectPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1318,9 +1318,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for SWARM_CONNECT_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -1359,9 +1359,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for SWARM_PEERS_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } SwarmPeersPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1370,9 +1370,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for SWARM_PEERS_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { @@ -1411,9 +1411,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for VERSION_POST_SUCCESS")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } VersionPostResponse::BadRequest(body) => { *response.status_mut() = StatusCode::from_u16(400) @@ -1422,9 +1422,9 @@ where CONTENT_TYPE, HeaderValue::from_str("application/json") .expect("Unable to create Content-Type header for VERSION_POST_BAD_REQUEST")); - let body = serde_json::to_string(&body) + let body_content = serde_json::to_string(&body) .expect("impossible to fail to serialize"); - *response.body_mut() = Body::from(body); + *response.body_mut() = Body::from(body_content); } }, Err(_) => { diff --git a/kubo-rpc/src/http.rs b/kubo-rpc/src/http.rs index 72c9d63a3..7774b44f1 100644 --- a/kubo-rpc/src/http.rs +++ b/kubo-rpc/src/http.rs @@ -606,9 +606,6 @@ mod tests { #[tokio::test] #[traced_test] async fn block_get_offline_not_found() { - // Test data from: - // https://ipld.io/specs/codecs/dag-pb/fixtures/cross-codec/#dagpb_data_some - let data = hex::decode("0a050001020304").unwrap(); let cid = Cid::from_str("bafybeibazl2z4vqp2tmwcfag6wirmtpnomxknqcgrauj7m2yisrz3qjbom").unwrap(); let mut mock_ipfs = MockIpfsDepTest::new();