diff --git a/apistos-gen-test/src/tests/api_error_derive_oas_3_0.rs b/apistos-gen-test/src/tests/api_error_derive_oas_3_0.rs index 5a0daa39..5d89dc8f 100644 --- a/apistos-gen-test/src/tests/api_error_derive_oas_3_0.rs +++ b/apistos-gen-test/src/tests/api_error_derive_oas_3_0.rs @@ -7,7 +7,7 @@ use std::collections::{BTreeMap, HashSet}; #[test] #[expect(dead_code)] fn api_component_derive() { - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(ApiErrorComponent)] #[openapi_error( status(code = 403), @@ -61,7 +61,7 @@ fn api_component_with_schema() { code: String, } - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(ApiErrorComponent)] #[openapi_error(status(code = 403), status(code = 409, description = "Too many requests"))] enum ErrorResponse { diff --git a/apistos-gen-test/src/tests/api_error_derive_oas_3_1.rs b/apistos-gen-test/src/tests/api_error_derive_oas_3_1.rs index e6ce0c01..700e58c5 100644 --- a/apistos-gen-test/src/tests/api_error_derive_oas_3_1.rs +++ b/apistos-gen-test/src/tests/api_error_derive_oas_3_1.rs @@ -7,7 +7,7 @@ use std::collections::{BTreeMap, HashSet}; #[test] #[expect(dead_code)] fn api_component_derive() { - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(ApiErrorComponent)] #[openapi_error( status(code = 403), @@ -61,7 +61,7 @@ fn api_component_with_schema() { code: String, } - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(ApiErrorComponent)] #[openapi_error(status(code = 403), status(code = 409, description = "Too many requests"))] enum ErrorResponse { diff --git a/apistos-gen-test/src/tests/api_operation_oas_3_0.rs b/apistos-gen-test/src/tests/api_operation_oas_3_0.rs index b3d93844..cf4415af 100644 --- a/apistos-gen-test/src/tests/api_operation_oas_3_0.rs +++ b/apistos-gen-test/src/tests/api_operation_oas_3_0.rs @@ -80,7 +80,7 @@ mod test_models { } } - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(Serialize, Deserialize, Debug, Clone, ApiErrorComponent)] #[openapi_error(status(code = 401), status(code = 403), status(code = 404), status(code = 405))] pub(crate) enum MultipleErrorResponse { @@ -221,7 +221,7 @@ fn api_operation_impl_responder() { HttpResponse::Ok() } - #[allow(clippy::todo, clippy::unused_async)] + #[expect(clippy::todo, clippy::unused_async, dead_code)] async fn plop() { todo!() } @@ -287,12 +287,12 @@ fn api_operation_impl_responder() { }) ); - let components = __openapi_test_async::components(); + let components = __openapi_test_async::components(OpenApiVersion::OAS3_0); // only one component here because: error does not have schema and Test is used both for query and response assert_eq!(components.len(), 1); let components = serde_json::to_value(components).expect("Unable to serialize as Json"); - let operation = __openapi_test_async::operation(); + let operation = __openapi_test_async::operation(OpenApiVersion::OAS3_0); let operation = serde_json::to_value(operation).expect("Unable to serialize as Json"); assert_json_eq!( diff --git a/apistos-gen-test/src/tests/api_operation_oas_3_1.rs b/apistos-gen-test/src/tests/api_operation_oas_3_1.rs index 2295ae80..e692f5f0 100644 --- a/apistos-gen-test/src/tests/api_operation_oas_3_1.rs +++ b/apistos-gen-test/src/tests/api_operation_oas_3_1.rs @@ -80,7 +80,7 @@ mod test_models { } } - #[allow(clippy::duplicated_attributes)] + #[expect(clippy::duplicated_attributes)] #[derive(Serialize, Deserialize, Debug, Clone, ApiErrorComponent)] #[openapi_error(status(code = 401), status(code = 403), status(code = 404), status(code = 405))] pub(crate) enum MultipleErrorResponse { @@ -209,6 +209,20 @@ fn api_operation_impl_responder() { HttpResponse::Ok() } + #[expect(clippy::todo, clippy::unused_async, dead_code)] + async fn plop() { + todo!() + } + + /// Add a new pet to the store + /// Add a new pet to the store + /// Plop + #[api_operation(tag = "pet")] + pub(crate) async fn test_async(_body: Json) -> impl Responder { + plop().await; + HttpResponse::Ok() + } + let components = __openapi_test::components(OpenApiVersion::OAS3_1); // only one component here because: error does not have schema and Test is used both for query and response assert_eq!(components.len(), 1); @@ -250,6 +264,48 @@ fn api_operation_impl_responder() { "deprecated": false }) ); + + let components = __openapi_test_async::components(OpenApiVersion::OAS3_1); + // only one component here because: error does not have schema and Test is used both for query and response + assert_eq!(components.len(), 1); + let components = serde_json::to_value(components).expect("Unable to serialize as Json"); + + let operation = __openapi_test_async::operation(OpenApiVersion::OAS3_1); + let operation = serde_json::to_value(operation).expect("Unable to serialize as Json"); + + assert_json_eq!(components, json!([{}])); + assert_json_eq!( + operation, + json!({ + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "description": "Add a new pet to the store\\\nPlop", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Test", + "type": "object", + "properties": { + "test": { + "type": "string" + } + }, + "required": [ + "test" + ] + } + } + }, + "required": true + }, + "responses": {}, + "deprecated": false + }) + ); } #[test] diff --git a/apistos/tests/default_parameters_oas_3_1.rs b/apistos/tests/default_parameters_oas_3_1.rs index 4ebeab8a..8a6bcce1 100644 --- a/apistos/tests/default_parameters_oas_3_1.rs +++ b/apistos/tests/default_parameters_oas_3_1.rs @@ -182,6 +182,7 @@ use apistos_rapidoc as _; use apistos_redoc as _; use apistos_scalar as _; use apistos_swagger_ui as _; +use futures_util as _; use garde_actix_web as _; use indexmap as _; use log as _; diff --git a/apistos/tests/query_parameters_oas_3_1.rs b/apistos/tests/query_parameters_oas_3_1.rs index b4ef5084..2cdcf84e 100644 --- a/apistos/tests/query_parameters_oas_3_1.rs +++ b/apistos/tests/query_parameters_oas_3_1.rs @@ -278,6 +278,7 @@ use apistos_rapidoc as _; use apistos_redoc as _; use apistos_scalar as _; use apistos_swagger_ui as _; +use futures_util as _; use indexmap as _; use log as _; use md5 as _;