diff --git a/modules/openapi-generator/src/main/resources/cpp-oatpp-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-oatpp-server/model-header.mustache index 9c1126ac8787..322867688f3d 100644 --- a/modules/openapi-generator/src/main/resources/cpp-oatpp-server/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-oatpp-server/model-header.mustache @@ -11,12 +11,15 @@ {{{defaultInclude}}} {{#imports}}{{{this}}} {{/imports}} +{{^isEnum}} #include "oatpp/core/macro/codegen.hpp" +{{/isEnum}} #include "oatpp/core/Types.hpp" namespace {{modelNamespace}} { +{{^isEnum}} /* Begin DTO code-generation */ #include OATPP_CODEGEN_BEGIN(DTO) @@ -28,19 +31,28 @@ class {{classname}} : public oatpp::DTO { DTO_INIT({{classname}}, DTO /* Extends */) {{#vars}} - DTO_FIELD({{#isModel}}oatpp::Object<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}, {{name}}); + DTO_FIELD({{#isModel}}oatpp::Object<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}, {{baseName}}); {{^required}} - DTO_FIELD(oatpp::Boolean, {{name}}IsSet);{{/required}} + DTO_FIELD(oatpp::Boolean, {{baseName}}IsSet);{{/required}} {{/vars}} - {{#isEnum}} // TODO: - {{classname}}::e{{classname}} m_value = {{classname}}::e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED;{{/isEnum}} - {{#vendorExtensions.x-is-string-enum-container}} // TODO: - {{#anyOf}}{{#-first}}{{{this}}} m_value;{{/-first}}{{/anyOf}}{{/vendorExtensions.x-is-string-enum-container}} }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) +{{/isEnum}} + +{{#isEnum}} +typedef {{dataType}} {{classname}}; +class {{classname}}Values { +public: +{{#allowableValues}} +{{#enumVars}} + static {{classname}} {{value}}(void) { return "{{value}}"; } +{{/enumVars}} +{{/allowableValues}} +}; +{{/isEnum}} } // namespace {{modelNamespace}} diff --git a/samples/server/petstore/cpp-oatpp/model/ApiResponse.hpp b/samples/server/petstore/cpp-oatpp/model/ApiResponse.hpp index 62f9ff35dab7..47b2960a79ad 100644 --- a/samples/server/petstore/cpp-oatpp/model/ApiResponse.hpp +++ b/samples/server/petstore/cpp-oatpp/model/ApiResponse.hpp @@ -35,20 +35,19 @@ class ApiResponse : public oatpp::DTO { DTO_INIT(ApiResponse, DTO /* Extends */) - DTO_FIELD(oatpp::Int32, Code); - DTO_FIELD(oatpp::Boolean, CodeIsSet); - DTO_FIELD(oatpp::String, Type); - DTO_FIELD(oatpp::Boolean, TypeIsSet); - DTO_FIELD(oatpp::String, Message); - DTO_FIELD(oatpp::Boolean, MessageIsSet); - - - + DTO_FIELD(oatpp::Int32, code); + DTO_FIELD(oatpp::Boolean, codeIsSet); + DTO_FIELD(oatpp::String, type); + DTO_FIELD(oatpp::Boolean, typeIsSet); + DTO_FIELD(oatpp::String, message); + DTO_FIELD(oatpp::Boolean, messageIsSet); + }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* ApiResponse_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/Category.hpp b/samples/server/petstore/cpp-oatpp/model/Category.hpp index 1b55023dcfab..158c73688754 100644 --- a/samples/server/petstore/cpp-oatpp/model/Category.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Category.hpp @@ -35,18 +35,17 @@ class Category : public oatpp::DTO { DTO_INIT(Category, DTO /* Extends */) - DTO_FIELD(oatpp::Int64, Id); - DTO_FIELD(oatpp::Boolean, IdIsSet); - DTO_FIELD(oatpp::String, Name); - DTO_FIELD(oatpp::Boolean, NameIsSet); + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::String, name); + DTO_FIELD(oatpp::Boolean, nameIsSet); - - }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* Category_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/Order.hpp b/samples/server/petstore/cpp-oatpp/model/Order.hpp index a7816394f986..3f69abb6a203 100644 --- a/samples/server/petstore/cpp-oatpp/model/Order.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Order.hpp @@ -35,26 +35,25 @@ class Order : public oatpp::DTO { DTO_INIT(Order, DTO /* Extends */) - DTO_FIELD(oatpp::Int64, Id); - DTO_FIELD(oatpp::Boolean, IdIsSet); - DTO_FIELD(oatpp::Int64, PetId); - DTO_FIELD(oatpp::Boolean, PetIdIsSet); - DTO_FIELD(oatpp::Int32, Quantity); - DTO_FIELD(oatpp::Boolean, QuantityIsSet); - DTO_FIELD(oatpp::String, ShipDate); - DTO_FIELD(oatpp::Boolean, ShipDateIsSet); - DTO_FIELD(oatpp::String, Status); - DTO_FIELD(oatpp::Boolean, StatusIsSet); - DTO_FIELD(oatpp::Boolean, Complete); - DTO_FIELD(oatpp::Boolean, CompleteIsSet); - - - + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::Int64, petId); + DTO_FIELD(oatpp::Boolean, petIdIsSet); + DTO_FIELD(oatpp::Int32, quantity); + DTO_FIELD(oatpp::Boolean, quantityIsSet); + DTO_FIELD(oatpp::String, shipDate); + DTO_FIELD(oatpp::Boolean, shipDateIsSet); + DTO_FIELD(oatpp::String, status); + DTO_FIELD(oatpp::Boolean, statusIsSet); + DTO_FIELD(oatpp::Boolean, complete); + DTO_FIELD(oatpp::Boolean, completeIsSet); + }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/Pet.hpp b/samples/server/petstore/cpp-oatpp/model/Pet.hpp index adfc608a1604..bc67ee40f41c 100644 --- a/samples/server/petstore/cpp-oatpp/model/Pet.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Pet.hpp @@ -37,26 +37,25 @@ class Pet : public oatpp::DTO { DTO_INIT(Pet, DTO /* Extends */) - DTO_FIELD(oatpp::Int64, Id); - DTO_FIELD(oatpp::Boolean, IdIsSet); - DTO_FIELD(oatpp::Object, Category); - DTO_FIELD(oatpp::Boolean, CategoryIsSet); - DTO_FIELD(oatpp::String, Name); + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::Object, category); + DTO_FIELD(oatpp::Boolean, categoryIsSet); + DTO_FIELD(oatpp::String, name); - DTO_FIELD(oatpp::Vector, PhotoUrls); + DTO_FIELD(oatpp::Vector, photoUrls); - DTO_FIELD(oatpp::Vector>, Tags); - DTO_FIELD(oatpp::Boolean, TagsIsSet); - DTO_FIELD(oatpp::String, Status); - DTO_FIELD(oatpp::Boolean, StatusIsSet); + DTO_FIELD(oatpp::Vector>, tags); + DTO_FIELD(oatpp::Boolean, tagsIsSet); + DTO_FIELD(oatpp::String, status); + DTO_FIELD(oatpp::Boolean, statusIsSet); - - }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* Pet_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/Tag.hpp b/samples/server/petstore/cpp-oatpp/model/Tag.hpp index b74619eebad9..f7941e8e3911 100644 --- a/samples/server/petstore/cpp-oatpp/model/Tag.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Tag.hpp @@ -35,18 +35,17 @@ class Tag : public oatpp::DTO { DTO_INIT(Tag, DTO /* Extends */) - DTO_FIELD(oatpp::Int64, Id); - DTO_FIELD(oatpp::Boolean, IdIsSet); - DTO_FIELD(oatpp::String, Name); - DTO_FIELD(oatpp::Boolean, NameIsSet); + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::String, name); + DTO_FIELD(oatpp::Boolean, nameIsSet); - - }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* Tag_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/User.hpp b/samples/server/petstore/cpp-oatpp/model/User.hpp index cd3d0b4ad54b..524a4e32f7f5 100644 --- a/samples/server/petstore/cpp-oatpp/model/User.hpp +++ b/samples/server/petstore/cpp-oatpp/model/User.hpp @@ -35,30 +35,29 @@ class User : public oatpp::DTO { DTO_INIT(User, DTO /* Extends */) - DTO_FIELD(oatpp::Int64, Id); - DTO_FIELD(oatpp::Boolean, IdIsSet); - DTO_FIELD(oatpp::String, Username); - DTO_FIELD(oatpp::Boolean, UsernameIsSet); - DTO_FIELD(oatpp::String, FirstName); - DTO_FIELD(oatpp::Boolean, FirstNameIsSet); - DTO_FIELD(oatpp::String, LastName); - DTO_FIELD(oatpp::Boolean, LastNameIsSet); - DTO_FIELD(oatpp::String, Email); - DTO_FIELD(oatpp::Boolean, EmailIsSet); - DTO_FIELD(oatpp::String, Password); - DTO_FIELD(oatpp::Boolean, PasswordIsSet); - DTO_FIELD(oatpp::String, Phone); - DTO_FIELD(oatpp::Boolean, PhoneIsSet); - DTO_FIELD(oatpp::Int32, UserStatus); - DTO_FIELD(oatpp::Boolean, UserStatusIsSet); + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::String, username); + DTO_FIELD(oatpp::Boolean, usernameIsSet); + DTO_FIELD(oatpp::String, firstName); + DTO_FIELD(oatpp::Boolean, firstNameIsSet); + DTO_FIELD(oatpp::String, lastName); + DTO_FIELD(oatpp::Boolean, lastNameIsSet); + DTO_FIELD(oatpp::String, email); + DTO_FIELD(oatpp::Boolean, emailIsSet); + DTO_FIELD(oatpp::String, password); + DTO_FIELD(oatpp::Boolean, passwordIsSet); + DTO_FIELD(oatpp::String, phone); + DTO_FIELD(oatpp::Boolean, phoneIsSet); + DTO_FIELD(oatpp::Int32, userStatus); + DTO_FIELD(oatpp::Boolean, userStatusIsSet); - - }; /* End DTO code-generation */ #include OATPP_CODEGEN_END(DTO) + } // namespace org::openapitools::server::model #endif /* User_H_ */