Added error-throw if no auth-handler was set up before controller is added to router or swagger-doc.

Also added missing undef for `OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_2` and `OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO_2`
This commit is contained in:
Benedikt-Alexander Mokroß 2019-09-04 08:54:53 +02:00
parent fb29f0d919
commit 7b0f6e64d0
2 changed files with 6 additions and 0 deletions

View File

@ -276,6 +276,8 @@ if(__param_obj_##NAME) { \
info->headers.add(oatpp::web::protocol::http::Header::AUTHORIZATION, oatpp::String::Class::getType()); \
info->headers[oatpp::web::protocol::http::Header::AUTHORIZATION].description = __param_obj_##NAME ->getScheme(); \
info->authorization = __param_obj_##NAME ->getScheme(); \
} else { \
throw oatpp::web::protocol::http::HttpError(Status::CODE_500, "No authorization handler set up in controller before controller was added to router or swagger-doc."); \
}
#define OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO_2(TYPE, NAME, AUTH_HANDLER) \
@ -284,6 +286,8 @@ if(__auth_handler_##NAME) { \
info->headers.add(oatpp::web::protocol::http::Header::AUTHORIZATION, oatpp::String::Class::getType()); \
info->headers[oatpp::web::protocol::http::Header::AUTHORIZATION].description = __auth_handler_##NAME->getScheme(); \
info->authorization = __auth_handler_##NAME->getScheme(); \
} else { \
throw oatpp::web::protocol::http::HttpError(Status::CODE_500, "Invalid authorization handler given (or not set up) in AUTHORIZATION(TYPE, NAME, AUTH_HANDLER) before controller was added to router or swagger-doc."); \
}
#define OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO(TYPE, PARAM_LIST) \

View File

@ -129,10 +129,12 @@
// AUTHORIZATION MACRO // ------------------------------------------------------
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_1
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_2
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION
// __INFO
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO_1
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO_2
#undef OATPP_MACRO_API_CONTROLLER_AUTHORIZATION_INFO
// FOR EACH // ------------------------------------------------------