Skip to content

Commit

Permalink
Merge pull request #17 from oatpp/add_oatpp_unsigned_types
Browse files Browse the repository at this point in the history
Add oatpp unsigned types
  • Loading branch information
lganzzzo authored Jan 26, 2020
2 parents 8e4a5d3 + 2385968 commit 136f09a
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 49 deletions.
Binary file modified res/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions res/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {

// Build a system
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "/api-docs/oas-3.0.0.json",
dom_id: '#swagger-ui',
Expand All @@ -52,6 +51,7 @@
],
layout: "StandaloneLayout"
})
// End Swagger UI call region

window.ui = ui
}
Expand Down
1 change: 1 addition & 0 deletions res/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<html lang="en-US">
<title>Swagger UI: OAuth2 Redirect</title>
<body onload="run()">
</body>
</html>
Expand Down
96 changes: 63 additions & 33 deletions res/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion res/swagger-ui-bundle.js.map

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions res/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion res/swagger-ui-standalone-preset.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion res/swagger-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion res/swagger-ui.css.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions res/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion res/swagger-ui.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/oatpp-swagger/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace oatpp { namespace swagger {

namespace __class {
const char* const Binary::CLASS_NAME = "string";
const oatpp::data::mapping::type::ClassId Binary::CLASS_ID("string");
}

}}
4 changes: 2 additions & 2 deletions src/oatpp-swagger/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ namespace __class {
/**
* CLASS_NAME = `"string"`.
*/
static const char* const CLASS_NAME;
static const oatpp::data::mapping::type::ClassId CLASS_ID;

/**
* Get type information.
* @return - &id:oatpp::data::mapping::type::Type;.
*/
static oatpp::data::mapping::type::Type* getType(){
static oatpp::data::mapping::type::Type type(CLASS_NAME, "binary");
static oatpp::data::mapping::type::Type type(CLASS_ID, "binary");
return &type;
}

Expand Down
46 changes: 45 additions & 1 deletion src/oatpp-swagger/oas3/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "oatpp/core/utils/ConversionUtils.hpp"

#include <limits>

namespace oatpp { namespace swagger { namespace oas3 {

Schema::ObjectWrapper Generator::generateSchemaForTypeObject(const oatpp::data::mapping::type::Type* type, bool linkSchema, UsedTypes& usedTypes) {
Expand Down Expand Up @@ -79,16 +81,51 @@ Schema::ObjectWrapper Generator::generateSchemaForType(const oatpp::data::mappin
auto result = Schema::createShared();
result->type = "string";
return result;
} else if(classId == oatpp::data::mapping::type::__class::Int8::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->minimum = std::numeric_limits<v_int8>::min();
result->maximum = std::numeric_limits<v_int8>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::UInt8::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->minimum = std::numeric_limits<v_uint8>::min();
result->maximum = std::numeric_limits<v_uint8>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::Int16::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->minimum = std::numeric_limits<v_int16>::min();
result->maximum = std::numeric_limits<v_int16>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::UInt16::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->minimum = std::numeric_limits<v_uint16>::min();
result->maximum = std::numeric_limits<v_uint16>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::Int32::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->format = "int32";
result->minimum = std::numeric_limits<v_int32>::min();
result->maximum = std::numeric_limits<v_int32>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::UInt32::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->minimum = std::numeric_limits<v_uint32>::min();
result->maximum = std::numeric_limits<v_uint32>::max();
return result;
} else if(classId == oatpp::data::mapping::type::__class::Int64::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
result->format = "int64";
return result;
} else if(classId == oatpp::data::mapping::type::__class::UInt64::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "integer";
return result;
} else if(classId == oatpp::data::mapping::type::__class::Float32::CLASS_ID.id){
auto result = Schema::createShared();
result->type = "number";
Expand Down Expand Up @@ -250,6 +287,13 @@ void Generator::generatePathItemData(const std::shared_ptr<Endpoint>& endpoint,
operation->operationId = info->name;
operation->summary = info->summary;
operation->description = info->description;

if(info->tags.size() > 0) {
operation->tags = operation->tags->createShared();
for(auto& tag : info->tags) {
operation->tags->pushBack(tag);
}
}

if(oatpp::base::StrBuffer::equalsCI("get", info->method->c_str(), info->method->getSize())) {
pathItem->operationGet = operation;
Expand Down
10 changes: 10 additions & 0 deletions src/oatpp-swagger/oas3/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ class Schema : public oatpp::data::mapping::type::Object {
*/
DTO_FIELD(String, format);

/**
* Minimum value.
*/
DTO_FIELD(Int64, minimum);

/**
* Maximum value.
*/
DTO_FIELD(Int64, maximum);

/**
* Map of &id:oatpp::String; to &l:Schema;.
*/
Expand Down

0 comments on commit 136f09a

Please sign in to comment.