AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
modelGenerator.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2026 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-oas-export.hpp"
23
24#include <stdexcept>
25#include <string>
26#include <vector>
27
28#include "oas/spec.hpp"
29
30namespace anch::oas {
31
39 struct ANCH_OAS_EXPORT ModelOptions {
41 std::string ns = "model";
42
44 std::string name = "models";
45
47 bool uuid = true;
48
51 bool date = true;
52
54 bool strict = false;
55
61 bool constraints = true;
62
68 bool server = false;
69
75 bool client = false;
76
81 std::string api;
82 };
83
91 struct ANCH_OAS_EXPORT GeneratedModels {
93 std::string header;
94
96 std::string source;
97
102 std::string serverHeader;
103
108 std::string serverSource;
109
114 std::string clientHeader;
115
120 std::string clientSource;
121
127 std::string formsHeader;
128
133 std::string formsSource;
134
137 std::vector<std::string> warnings;
138 };
139
147 class ANCH_OAS_EXPORT GeneratorError: public std::runtime_error {
148 public:
154 explicit GeneratorError(const std::string& message);
155 };
156
194
195} // anch::oas
GeneratorError(const std::string &message)
OpenAPI namespace.
Definition modelGenerator.hpp:30
anch::oas::GeneratedModels generateModels(const anch::oas::OpenAPI &api, const anch::oas::ModelOptions &options)
Generated models.
Definition modelGenerator.hpp:91
std::string serverSource
Definition modelGenerator.hpp:108
std::string source
Definition modelGenerator.hpp:96
std::string header
Definition modelGenerator.hpp:93
std::string clientSource
Definition modelGenerator.hpp:120
std::vector< std::string > warnings
Definition modelGenerator.hpp:137
std::string serverHeader
Definition modelGenerator.hpp:102
std::string clientHeader
Definition modelGenerator.hpp:114
std::string formsHeader
Definition modelGenerator.hpp:127
std::string formsSource
Definition modelGenerator.hpp:133
Models generation options.
Definition modelGenerator.hpp:39
bool client
Definition modelGenerator.hpp:75
bool constraints
Definition modelGenerator.hpp:61
bool uuid
Definition modelGenerator.hpp:47
std::string name
Definition modelGenerator.hpp:44
std::string api
Definition modelGenerator.hpp:81
std::string ns
Definition modelGenerator.hpp:41
bool server
Definition modelGenerator.hpp:68
bool date
Definition modelGenerator.hpp:51
bool strict
Definition modelGenerator.hpp:54
OpenAPI 3.0 document (models and endpoints parts).
Definition spec.hpp:413