diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache index 221b3f138cc1..aa9a8cc7051c 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache @@ -38,6 +38,11 @@ use {{{operationId}}}Response; {{/operations}} {{/apis}} {{/apiInfo}} +{{#callbacks}} + {{#pathSet}} + _ if path.matched(paths::ID_{{PATH_ID}}) => method_not_allowed(), + {{/pathSet}} +{{/callbacks}} {{>server-service-footer}} /// Request parser for `Api`. pub struct ApiRequestParser; diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache index efdc16c19102..198bff6a9b55 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache @@ -19,6 +19,9 @@ pub mod callbacks; {{/operations}} {{/apis}} {{/apiInfo}} +{{#pathSet}} + _ if path.matched(paths::ID_{{PATH_ID}}) => method_not_allowed(), +{{/pathSet}} {{>server-service-footer}} /// Request parser for `Api`. pub struct ApiRequestParser; diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache index 790232885035..da785bbbfb45 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache @@ -1,3 +1,13 @@ +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -23,7 +33,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs index d81445de44c9..0af9ae463637 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs @@ -84,6 +84,16 @@ where } } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -109,7 +119,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -425,6 +435,8 @@ where ) }, + _ if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPART_REQUEST) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty()) diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index 1c59c9cae122..b02cc63610cf 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -91,6 +91,16 @@ where } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -116,7 +126,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -230,6 +240,8 @@ where }) as Self::Future }, + _ if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => method_not_allowed(), + _ if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty()) diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index 6b8dd8cf72a8..939223c1fcae 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -134,6 +134,16 @@ where } } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -159,7 +169,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -1404,6 +1414,23 @@ where ) as Self::Future }, + _ if path.matched(paths::ID_CALLBACK_WITH_HEADER) => method_not_allowed(), + _ if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => method_not_allowed(), + _ if path.matched(paths::ID_MERGE_PATCH_JSON) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIGET) => method_not_allowed(), + _ if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => method_not_allowed(), + _ if path.matched(paths::ID_PARAMGET) => method_not_allowed(), + _ if path.matched(paths::ID_READONLY_AUTH_SCHEME) => method_not_allowed(), + _ if path.matched(paths::ID_REGISTER_CALLBACK) => method_not_allowed(), + _ if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => method_not_allowed(), + _ if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => method_not_allowed(), + _ if path.matched(paths::ID_RFC7807) => method_not_allowed(), + _ if path.matched(paths::ID_UNTYPED_PROPERTY) => method_not_allowed(), + _ if path.matched(paths::ID_UUID) => method_not_allowed(), + _ if path.matched(paths::ID_XML) => method_not_allowed(), + _ if path.matched(paths::ID_XML_EXTRA) => method_not_allowed(), + _ if path.matched(paths::ID_XML_OTHER) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty()) diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index 99bf35171e37..9f2e19d645f4 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -183,6 +183,16 @@ where } } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -208,7 +218,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -1552,6 +1562,43 @@ where }) as Self::Future }, + _ if path.matched(paths::ID_OP1) => method_not_allowed(), + _ if path.matched(paths::ID_OP10) => method_not_allowed(), + _ if path.matched(paths::ID_OP11) => method_not_allowed(), + _ if path.matched(paths::ID_OP12) => method_not_allowed(), + _ if path.matched(paths::ID_OP13) => method_not_allowed(), + _ if path.matched(paths::ID_OP14) => method_not_allowed(), + _ if path.matched(paths::ID_OP15) => method_not_allowed(), + _ if path.matched(paths::ID_OP16) => method_not_allowed(), + _ if path.matched(paths::ID_OP17) => method_not_allowed(), + _ if path.matched(paths::ID_OP18) => method_not_allowed(), + _ if path.matched(paths::ID_OP19) => method_not_allowed(), + _ if path.matched(paths::ID_OP2) => method_not_allowed(), + _ if path.matched(paths::ID_OP20) => method_not_allowed(), + _ if path.matched(paths::ID_OP21) => method_not_allowed(), + _ if path.matched(paths::ID_OP22) => method_not_allowed(), + _ if path.matched(paths::ID_OP23) => method_not_allowed(), + _ if path.matched(paths::ID_OP24) => method_not_allowed(), + _ if path.matched(paths::ID_OP25) => method_not_allowed(), + _ if path.matched(paths::ID_OP26) => method_not_allowed(), + _ if path.matched(paths::ID_OP27) => method_not_allowed(), + _ if path.matched(paths::ID_OP28) => method_not_allowed(), + _ if path.matched(paths::ID_OP29) => method_not_allowed(), + _ if path.matched(paths::ID_OP3) => method_not_allowed(), + _ if path.matched(paths::ID_OP30) => method_not_allowed(), + _ if path.matched(paths::ID_OP31) => method_not_allowed(), + _ if path.matched(paths::ID_OP32) => method_not_allowed(), + _ if path.matched(paths::ID_OP33) => method_not_allowed(), + _ if path.matched(paths::ID_OP34) => method_not_allowed(), + _ if path.matched(paths::ID_OP35) => method_not_allowed(), + _ if path.matched(paths::ID_OP36) => method_not_allowed(), + _ if path.matched(paths::ID_OP37) => method_not_allowed(), + _ if path.matched(paths::ID_OP4) => method_not_allowed(), + _ if path.matched(paths::ID_OP5) => method_not_allowed(), + _ if path.matched(paths::ID_OP6) => method_not_allowed(), + _ if path.matched(paths::ID_OP7) => method_not_allowed(), + _ if path.matched(paths::ID_OP8) => method_not_allowed(), + _ if path.matched(paths::ID_OP9) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty()) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 3de5c24d96a5..a3cd9858235a 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -190,6 +190,16 @@ where } } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -215,7 +225,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -3061,6 +3071,33 @@ where ) as Self::Future }, + _ if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_JSONFORMDATA) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_NUMBER) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_OUTER_STRING) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => method_not_allowed(), + _ if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => method_not_allowed(), + _ if path.matched(paths::ID_PET) => method_not_allowed(), + _ if path.matched(paths::ID_PET_FINDBYSTATUS) => method_not_allowed(), + _ if path.matched(paths::ID_PET_FINDBYTAGS) => method_not_allowed(), + _ if path.matched(paths::ID_PET_PETID) => method_not_allowed(), + _ if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_INVENTORY) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_ORDER) => method_not_allowed(), + _ if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => method_not_allowed(), + _ if path.matched(paths::ID_USER) => method_not_allowed(), + _ if path.matched(paths::ID_USER_CREATEWITHARRAY) => method_not_allowed(), + _ if path.matched(paths::ID_USER_CREATEWITHLIST) => method_not_allowed(), + _ if path.matched(paths::ID_USER_LOGIN) => method_not_allowed(), + _ if path.matched(paths::ID_USER_LOGOUT) => method_not_allowed(), + _ if path.matched(paths::ID_USER_USERNAME) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty()) diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index 56a06660da88..96a10eee30df 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -97,6 +97,16 @@ where } } +type ServiceFuture = Box, Error = Error> + Send>; + +fn method_not_allowed() -> ServiceFuture { + Box::new(future::ok( + Response::builder().status(StatusCode::METHOD_NOT_ALLOWED) + .body(Body::empty()) + .expect("Unable to create Method Not Allowed response") + )) +} + pub struct Service { api_impl: T, marker: PhantomData, @@ -122,7 +132,7 @@ where type ReqBody = ContextualPayload; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = ServiceFuture; fn call(&mut self, req: Request) -> Self::Future { let api_impl = self.api_impl.clone(); @@ -641,6 +651,14 @@ where ) as Self::Future }, + _ if path.matched(paths::ID_ALLOF) => method_not_allowed(), + _ if path.matched(paths::ID_DUMMY) => method_not_allowed(), + _ if path.matched(paths::ID_FILE_RESPONSE) => method_not_allowed(), + _ if path.matched(paths::ID_GET_STRUCTURED_YAML) => method_not_allowed(), + _ if path.matched(paths::ID_HTML) => method_not_allowed(), + _ if path.matched(paths::ID_POST_YAML) => method_not_allowed(), + _ if path.matched(paths::ID_RAW_JSON) => method_not_allowed(), + _ if path.matched(paths::ID_SOLO_OBJECT) => method_not_allowed(), _ => Box::new(future::ok( Response::builder().status(StatusCode::NOT_FOUND) .body(Body::empty())