sptk2 logo
SPTK Home Page
OpenApiGenerator.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/wsdl/WSOperation.h>
30#include <sptk5/xdoc/Document.h>
31
32namespace sptk {
33
37class SP_EXPORT OpenApiGenerator
38{
39public:
40
44 enum class AuthMethod
45 : uint8_t
46 {
47 NONE,
48 BASIC,
49 BEARER
50 };
51
55 struct Options
56 {
60 AuthMethod defaultAuthMethod {AuthMethod::BEARER};
61
65 std::map<String, AuthMethod> operationsAuth;
66
71 };
72
81 OpenApiGenerator(const String& title, const String& description, const String& version,
82 const Strings& servers, const Options& options);
83
91 void generate(std::ostream& output, const WSOperationMap& operations, const WSComplexTypeMap& complexTypes,
92 const std::map<String, String>& documentation) const;
93
94 static AuthMethod authMethod(const String& auth);
95
96 static String authMethodName(AuthMethod auth);
97
98private:
99
105 void createComponents(xdoc::Document& document, const WSComplexTypeMap& complexTypes) const;
106
113 void createPaths(xdoc::Document& document, const WSOperationMap& operations,
114 const std::map<String, String>& documentation) const;
115
120 void createServers(xdoc::Document& document) const;
121
122 const String m_title;
123 const String m_description;
124 const String m_version;
125 const Strings m_servers;
126 const Options m_options;
127
128 void parseClassName(const SWSParserComplexType& ctypeProperty, const xdoc::SNode& property) const;
129
130 void parseRestriction(const SWSParserComplexType& ctypeProperty, const xdoc::SNode& property) const;
131
132 void parseRestrictionPatterns(const xdoc::SNode& property, const SWSRestriction& restriction) const;
133};
134
135}
Definition: OpenApiGenerator.h:38
AuthMethod
Definition: OpenApiGenerator.h:46
OpenApiGenerator(const String &title, const String &description, const String &version, const Strings &servers, const Options &options)
void generate(std::ostream &output, const WSOperationMap &operations, const WSComplexTypeMap &complexTypes, const std::map< String, String > &documentation) const
Definition: String.h:49
Definition: Strings.h:52
Definition: Document.h:34
std::map< String, SWSParserComplexType > WSComplexTypeMap
Definition: WSParserComplexType.h:302
std::map< String, WSOperation > WSOperationMap
Definition: WSOperation.h:56
Definition: OpenApiGenerator.h:56
std::map< String, AuthMethod > operationsAuth
Definition: OpenApiGenerator.h:65
String openApiFile
Definition: OpenApiGenerator.h:70

Fri Oct 14 2022 09:58:32: SPTK 5.4.1