Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
87b534f
feat(chaotic-openapi): pass RequestContext to generated View::Handle
lemito Aug 14, 2026
97ba9b4
chore(chaotic-openapi): update golden tests and views for View::Handl…
lemito Aug 14, 2026
9217456
docs(chaotic-openapi): document View::Handle RequestContext contract
lemito Aug 14, 2026
3658eda
fix(chaotic-openapi): fix int_tests
lemito Aug 14, 2026
761a6e6
refactor(chaotic-openapi): require RequestContext in View::Handle
lemito Aug 16, 2026
e4f4bae
chore(chaotic-openapi): update views for RequestContext alias
lemito Aug 16, 2026
830323a
feat(samples): add chaotic_openapi_auth_service sample
lemito Aug 16, 2026
770bf83
test(chaotic-openapi): add view renderer unit tests
lemito Aug 16, 2026
60e5a09
docs(chaotic-openapi): document auth via RequestContext
lemito Aug 16, 2026
b2fc748
revert(chaotic-openapi): drop redundant docs, mapping and sample changes
lemito Aug 16, 2026
733f088
fix(chaotic-openapi): update handler logging test for RequestContext …
lemito Aug 17, 2026
32af417
feat(samples): demonstrate RequestContext auth in chaotic_openapi_ser…
lemito Aug 17, 2026
8a04195
refactor(samples): move greetingGet to a separate secure schema
lemito Aug 17, 2026
c996465
feat(samples): validate bearer tokens against secdist in chaotic_open…
lemito Aug 17, 2026
db145ae
feat(chaotic-openapi): add ChaoticHandlersListWithoutFactories()
lemito Aug 17, 2026
e602b54
ERROR
lemito Aug 18, 2026
a6913d9
fix(chopen)/fix ch-openapi factories
lemito Aug 18, 2026
5f22fad
fix: bad config add
lemito Aug 18, 2026
07f8538
fix(chaotic): build config.yaml with the service binary
lemito Aug 18, 2026
e5879d9
fix(chgen): reformat
lemito Aug 20, 2026
886232a
fix(chgen): reformat code
lemito Aug 20, 2026
460e610
fix(chgen): regenerate golden tests output with formatting
lemito Aug 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace {{ spec.cpp_namespace }} {
/// @endcode
inline {{ userver }}::components::ComponentList ChaoticHandlersList() {
return {{ userver }}::components::ComponentList()
.Append<{{ userver }}::components::Container<
{{ userver }}::chaotic::openapi::server::dependencies::Factories>>()
{% for op in spec.operations %}
.Append<{{ spec.cpp_namespace }}::{{ op.cpp_namespace() }}::Handler>()
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace {{ spec.cpp_namespace }}::{{ op.cpp_namespace() }} {

Response View::Handle(Request&& /*request*/, Deps&& /*deps*/) {
Response View::Handle(
Request&& /*request*/,
Deps&& /*deps*/,
RequestContext& /*context*/) {
// Handle request using dependencies from Deps (clients, caches, configs, databases...)
return {};
}
Expand Down Expand Up @@ -32,7 +35,7 @@ std::string View::GetRequestBodyForLogging(const std::string& body) {
std::string View::GetResponseForLogging(
const Response& response,
const std::string& serialized_response,
{{ userver }}::server::request::RequestContext& context) {
RequestContext& context) {
(void)response;
(void)serialized_response;
(void)context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ struct HandlerTag;
class View final {
public:
using Deps = {{ userver }}::chaotic::openapi::server::dependencies::ForHandler<HandlerTag>;
using RequestContext = {{ userver }}::server::request::RequestContext;

static Response Handle(Request&& request, Deps&& deps);
static Response Handle(Request&& request, Deps&& deps, RequestContext& context);

/* Uncomment, if you want to define a custom logging for request/response body.
* E.g. you want to log several fields, but omit the others (secrets, etc.).
Expand All @@ -40,7 +41,7 @@ public:
static std::string GetResponseForLogging(
const Response& response,
const std::string& serialized_response,
{{ userver }}::server::request::RequestContext& context);
RequestContext& context);
*/
};

Expand Down
4 changes: 2 additions & 2 deletions chaotic-openapi/golden_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ userver_target_generate_openapi_client(
${PROJECT_NAME}-chgen-client
NAME test
OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/client"
FORMAT OFF
FORMAT ON
SCHEMAS ${SCHEMAS}
)

Expand All @@ -18,7 +18,7 @@ userver_target_generate_openapi_handlers(
NAME test
OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/handlers"
SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/src/handlers"
FORMAT OFF
FORMAT ON
SCHEMAS ${SCHEMAS}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

#include <userver/chaotic/openapi/client/command_control.hpp>

#include "requests.hpp"
#include "responses.hpp"

#include <userver/chaotic/openapi/client/command_control.hpp>

namespace clients::test {

class Client {
public:
/// POST /testme
/// A testing method to call
/// @throw testme::post::Exception
public:
/// POST /testme
/// A testing method to call
/// @throw testme::post::Exception

virtual testme::post::Response TestmePost(const testme::post::Request& request , const USERVER_NAMESPACE::chaotic::openapi::client::CommandControl& command_control = {}) = 0;
virtual testme::post::Response TestmePost(
const testme::post::Request& request,
const USERVER_NAMESPACE::chaotic::openapi::client::CommandControl& command_control = {}) = 0;

virtual ~Client();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace clients::test {

class Client;

} // namespace clients::test
} // namespace clients::test
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,50 @@
#pragma once

#include <clients/test/client.hpp>

#include <userver/chaotic/openapi/client/config.hpp>
#include <userver/chaotic/openapi/middlewares/manager.hpp>
#include <userver/clients/http/client.hpp>
#include <userver/components/component_config.hpp>
#include <userver/yaml_config/schema.hpp>

#include <userver/clients/http/client.hpp>

namespace clients::test {

class ClientImpl final : public Client {
public:
// API
public:
// API

testme::post::Response TestmePost(const testme::post::Request& request , const USERVER_NAMESPACE::chaotic::openapi::client::CommandControl& command_control = {}
) override;
testme::post::Response TestmePost(
const testme::post::Request& request,
const USERVER_NAMESPACE::chaotic::openapi::client::CommandControl& command_control = {}) override;

// end of API
// end of API

static constexpr std::string_view kName = "test";
static constexpr std::string_view kDefaultBaseUrl = "http://example.com";
static constexpr std::string_view kName = "test";
static constexpr std::string_view kDefaultBaseUrl = "http://example.com";

ClientImpl(const USERVER_NAMESPACE::chaotic::openapi::client::Config& config,
USERVER_NAMESPACE::clients::http::Client& http_client);
ClientImpl(const USERVER_NAMESPACE::chaotic::openapi::client::Config& config,
USERVER_NAMESPACE::clients::http::Client& http_client);

static USERVER_NAMESPACE::yaml_config::Schema GetStaticConfigSchema();
static USERVER_NAMESPACE::yaml_config::Schema GetStaticConfigSchema();

void RegisterMiddleware(std::shared_ptr<USERVER_NAMESPACE::chaotic::openapi::client::Middleware> middleware) {
middleware_manager_.RegisterMiddleware(middleware);
}
void RegisterMiddleware(std::shared_ptr<USERVER_NAMESPACE::chaotic::openapi::client::Middleware> middleware) {
middleware_manager_.RegisterMiddleware(middleware);
}

void SetCoreMiddlewares(std::optional<std::vector<USERVER_NAMESPACE::utils::NotNull<USERVER_NAMESPACE::clients::http::MiddlewareBase*>>> core_middlewares) {
core_middlewares_ = std::move(core_middlewares);
}
void SetCoreMiddlewares(
std::optional<std::vector<USERVER_NAMESPACE::utils::NotNull<USERVER_NAMESPACE::clients::http::MiddlewareBase*>>>
core_middlewares) {
core_middlewares_ = std::move(core_middlewares);
}

private:
USERVER_NAMESPACE::chaotic::openapi::client::Config config_;
USERVER_NAMESPACE::clients::http::Client& http_client_;
USERVER_NAMESPACE::chaotic::openapi::MiddlewareManager middleware_manager_;
std::unordered_map<std::string, std::shared_ptr<USERVER_NAMESPACE::chaotic::openapi::client::Middleware>> middlewares_;
std::optional<std::vector<USERVER_NAMESPACE::utils::NotNull<USERVER_NAMESPACE::clients::http::MiddlewareBase*>>> core_middlewares_;
private:
USERVER_NAMESPACE::chaotic::openapi::client::Config config_;
USERVER_NAMESPACE::clients::http::Client& http_client_;
USERVER_NAMESPACE::chaotic::openapi::MiddlewareManager middleware_manager_;
std::unordered_map<std::string, std::shared_ptr<USERVER_NAMESPACE::chaotic::openapi::client::Middleware>>
middlewares_;
std::optional<std::vector<USERVER_NAMESPACE::utils::NotNull<USERVER_NAMESPACE::clients::http::MiddlewareBase*>>>
core_middlewares_;
};

}
} // namespace clients::test
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

#include <clients/test/client_impl.hpp>
#include <userver/components/component_base.hpp>
#include <userver/yaml_config/schema.hpp>

#include <clients/test/client_impl.hpp>

namespace clients::test {

class Component final : public USERVER_NAMESPACE::components::ComponentBase {
public:
static constexpr std::string_view kName = "test-client";
public:
static constexpr std::string_view kName = "test-client";

Component(const USERVER_NAMESPACE::components::ComponentConfig& config, const USERVER_NAMESPACE::components::ComponentContext& context);
Component(const USERVER_NAMESPACE::components::ComponentConfig& config,
const USERVER_NAMESPACE::components::ComponentContext& context);

Client& GetClient();
Client& GetClient();

static USERVER_NAMESPACE::yaml_config::Schema GetStaticConfigSchema();
static USERVER_NAMESPACE::yaml_config::Schema GetStaticConfigSchema();

private:
ClientImpl client_;
private:
ClientImpl client_;
};

} // namespace clients::test

template<>
inline constexpr auto USERVER_NAMESPACE::components::kConfigFileMode<::clients::test::Component>
= USERVER_NAMESPACE::components::ConfigFileMode::kNotRequired;
template <>
inline constexpr auto USERVER_NAMESPACE::components::kConfigFileMode<::clients::test::Component> =
USERVER_NAMESPACE::components::ConfigFileMode::kNotRequired;
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,26 @@
namespace clients::test {

/// @brief Base class for test client exceptions
class Exception: public USERVER_NAMESPACE::chaotic::openapi::client::Exception {
class Exception : public USERVER_NAMESPACE::chaotic::openapi::client::Exception {
public:
using USERVER_NAMESPACE::chaotic::openapi::client::Exception::Exception;
~Exception();
};

/// @brief Response with ErrorKind for test client exceptions
class HttpException : public USERVER_NAMESPACE::chaotic::openapi::client::HttpException
{
class HttpException : public USERVER_NAMESPACE::chaotic::openapi::client::HttpException {
public:
explicit HttpException(USERVER_NAMESPACE::clients::http::ErrorKind error_kind);
explicit HttpException(USERVER_NAMESPACE::clients::http::ErrorKind error_kind);
};

/// @brief Response with HTTP status code for test client exceptions
class ExceptionWithStatusCode : public USERVER_NAMESPACE::chaotic::openapi::client::ExceptionWithStatusCode
{
class ExceptionWithStatusCode : public USERVER_NAMESPACE::chaotic::openapi::client::ExceptionWithStatusCode {
public:
ExceptionWithStatusCode(int status_code);
ExceptionWithStatusCode(int status_code);
};

/// @brief Timeout exception class for test client exceptions
class TimeoutException: public USERVER_NAMESPACE::chaotic::openapi::client::TimeoutException {
class TimeoutException : public USERVER_NAMESPACE::chaotic::openapi::client::TimeoutException {
public:
using USERVER_NAMESPACE::chaotic::openapi::client::TimeoutException::TimeoutException;
~TimeoutException();
Expand All @@ -36,41 +34,32 @@ class TimeoutException: public USERVER_NAMESPACE::chaotic::openapi::client::Time
namespace testme::post {

/// @brief Base exception class for all client POST operations with URL '/testme'
class Exception: public ::clients::test::Exception {
class Exception : public ::clients::test::Exception {
public:
const char* what() const noexcept override;
const char* what() const noexcept override;

static constexpr USERVER_NAMESPACE::utils::zstring_view kHandlerInfo{"POST /testme"};
static constexpr USERVER_NAMESPACE::utils::zstring_view kHandlerInfo{"POST /testme"};
};

/// @brief Error response with ErrorKind for all client POST operations with URL '/testme'
class HttpException
: public Exception
, public ::clients::test::HttpException
{
public:
using ::clients::test::HttpException::HttpException;
~HttpException();
class HttpException : public Exception, public ::clients::test::HttpException {
public:
using ::clients::test::HttpException::HttpException;
~HttpException();
};

/// @brief Timeout exception class for all client POST operations with URL '/testme'
class TimeoutException
: public HttpException
, public ::clients::test::TimeoutException
{
public:
TimeoutException();
~TimeoutException();
class TimeoutException : public HttpException, public ::clients::test::TimeoutException {
public:
TimeoutException();
~TimeoutException();
};

/// @brief Error response with HTTP status code for all client POST operations with URL '/testme'
class ExceptionWithStatusCode
: public Exception
, public ::clients::test::ExceptionWithStatusCode
{
public:
using ::clients::test::ExceptionWithStatusCode::ExceptionWithStatusCode;
~ExceptionWithStatusCode();
class ExceptionWithStatusCode : public Exception, public ::clients::test::ExceptionWithStatusCode {
public:
using ::clients::test::ExceptionWithStatusCode::ExceptionWithStatusCode;
~ExceptionWithStatusCode();
};

} // namespace testme::post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

#include "clients/test/openapi_fwd.hpp"

#include <string>
#include <userver/chaotic/io/std/vector.hpp>

#include <userver/chaotic/type_bundle_hpp.hpp>

namespace clients {namespace test {namespace testme {namespace post {
#include "clients/test/openapi_fwd.hpp"

namespace clients {
namespace test {
namespace testme {
namespace post {

using Parameter1 = std::vector<std::string>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

namespace clients {namespace test {namespace testme {namespace post {

} // namespace post
namespace clients {
namespace test {
namespace testme {
namespace post {} // namespace post
} // namespace testme
} // namespace test
} // namespace clients
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

#include "clients/test/openapi.hpp"

#include <userver/chaotic/array.hpp>
#include <userver/chaotic/primitive.hpp>
#include <userver/chaotic/validators.hpp>
#include <userver/chaotic/with_type.hpp>

namespace clients {namespace test {namespace testme {namespace post {
#include "clients/test/openapi.hpp"

} // namespace post
namespace clients {
namespace test {
namespace testme {
namespace post {} // namespace post
} // namespace testme
} // namespace test
} // namespace clients
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* THIS FILE IS AUTOGENERATED, DON'T EDIT! */
#pragma once

#include "clients/test/openapi.hpp"

#include <userver/chaotic/array.hpp>
#include <userver/chaotic/primitive.hpp>
#include <userver/chaotic/sax_parser.hpp>
#include <userver/chaotic/validators.hpp>
#include <userver/chaotic/with_type.hpp>
#include <userver/chaotic/sax_parser.hpp>

namespace clients {namespace test {namespace testme {namespace post {
#include "clients/test/openapi.hpp"

} // namespace post
namespace clients {
namespace test {
namespace testme {
namespace post {} // namespace post
} // namespace testme
} // namespace test
} // namespace clients
Loading
Loading