Files
openapi-generator/samples/server/petstore/cpp-pistache-everything/impl/UserApiImpl.cpp
KRJ-RTX 18b359ba17 Add Basic and Bearer Authorization to the CPP Pistache generator (#22337)
* [cpp][pistache-server] Add extraction and forwarding of credentials for HTTP Basic protected endpoints.

* [cpp][pistache-server] Change HTTP Basic credentials to be contained on a struct instead of two std::strings

* [cpp][pistache-server] Add callbacks to authenticate http basic credentials.

* [cpp][pistache-server] Add `void* userdata` to HttpBasicCredentials.

This allows for data ft be passed on from the authenticator to the
handler implementation. For example a userid that has already been
looked up

* [cpp][pistache-server] Add support for HTTP Bearer authentication.

* [cpp][pistache-server] Add new file `api-base-source.mustache`

`api-base-source.mustache` contain implementations of security
related methods and also the empty constructor.

* [cpp][pistache-server] Add re-generated samples.

* Fix PR 19978: Updated indentation levels and fixed test problems

---------

Co-authored-by: Morten Winkler <morten@winkler.dk>
2025-12-02 10:07:47 +08:00

62 lines
2.1 KiB
C++

/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "UserApiImpl.h"
namespace org {
namespace openapitools {
namespace server {
namespace api {
using namespace org::openapitools::server::model;
UserApiImpl::UserApiImpl(const std::shared_ptr<Pistache::Rest::Router>& rtr)
: UserApi(rtr)
{
}
void UserApiImpl::create_user(const User &user, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::create_users_with_array_input(const std::vector<org::openapitools::server::model::User> &user, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::create_users_with_list_input(const std::vector<org::openapitools::server::model::User> &user, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::delete_user(const std::string &username, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::login_user(const std::optional<std::string> &username, const std::optional<std::string> &password, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::logout_user(Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void UserApiImpl::update_user(const std::string &username, const User &user, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
}
}
}
}