File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,22 @@ compile_test_library(
7474 "${PROJECT_SOURCE_DIR } /test" # Test directory
7575)
7676
77+ ###############################################################################
78+ # Resources
79+ ###############################################################################
80+ file (READ "${PROJECT_SOURCE_DIR } /../resources/configurations/ddsrouter_config_schema.json"
81+ DDSROUTER_CONFIG_SCHEMA_CONTENT )
82+
83+ configure_file (
84+ "${PROJECT_SOURCE_DIR } /include/ddsrouter_yaml/DdsRouterConfigSchema.hpp.in"
85+ "${CMAKE_CURRENT_BINARY_DIR } /include/ddsrouter_yaml/DdsRouterConfigSchema.hpp"
86+ @ONLY
87+ )
88+
89+ target_include_directories (${MODULE_NAME} PUBLIC
90+ $<BUILD_INTERFACE :${CMAKE_CURRENT_BINARY_DIR } /include >
91+ )
92+
7793###############################################################################
7894# Packaging
7995###############################################################################
Original file line number Diff line number Diff line change 1+ // Copyright 2026 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ #pragma once
16+
17+ static const char* DDSROUTER_CONFIG_SCHEMA = R"json(@DDSROUTER_CONFIG_SCHEMA_CONTENT@)json";
Original file line number Diff line number Diff line change 1616#include < ddspipe_yaml/Yaml.hpp>
1717#include < ddspipe_yaml/YamlManager.hpp>
1818#include < ddspipe_yaml/YamlReader.hpp>
19+ #include < ddspipe_yaml/YamlValidator.hpp>
1920
2021#include < ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
2122
2223#include < ddsrouter_yaml/YamlReaderConfiguration.hpp>
24+ #include < ddsrouter_yaml/DdsRouterConfigSchema.hpp>
2325
2426namespace eprosima {
2527namespace ddsrouter {
@@ -30,6 +32,15 @@ YamlReaderConfiguration::load_ddsrouter_configuration(
3032 const Yaml& yml,
3133 const CommandlineArgsRouter* args /* = nullptr*/ )
3234{
35+ // Ensure the Yaml is valid
36+ ddspipe::yaml::YamlValidator validator = ddspipe::yaml::YamlValidator (
37+ ddspipe::yaml::YamlValidator::from_string (DDSROUTER_CONFIG_SCHEMA ));
38+ if (!validator.validate_YAML (yml))
39+ {
40+ throw eprosima::utils::ConfigurationException (
41+ utils::Formatter () << " Error, the provided yaml file is not a valid ddsrouter configuration.\n " );
42+ }
43+
3344 try
3445 {
3546 ddspipe::yaml::YamlReaderVersion version;
You can’t perform that action at this time.
0 commit comments