MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mrs::rest::OpenApiCreator Class Reference

Helper class that facilitates generating OpenAPI swagger for the given DBobject entry. More...

Public Member Functions

 OpenApiCreator (DbObjectPtr entry, rapidjson::Document::AllocatorType &allocator)
 
rapidjson::Value create_get_method () const
 Create HTTP GET method contents for OpenAPI path. More...
 
rapidjson::Value create_get_by_key_method () const
 Create HTTP GET method contents for OpenAPI path. More...
 
rapidjson::Value create_post_method () const
 Create HTTP POST method contents for OpenAPI path. More...
 
rapidjson::Value create_delete_method () const
 Create HTTP DELETE method contents for OpenAPI path. More...
 
rapidjson::Value create_delete_by_key_method () const
 Create HTTP DELETE method contents for OpenAPI path. More...
 
rapidjson::Value create_put_method () const
 Create HTTP PUT method contents for OpenAPI path. More...
 
rapidjson::Value create_components () const
 Create OpenAPI components for the current entry. More...
 
bool has_primary_key () const
 Information if the current entry contain Primary Key configured. More...
 
std::string primary_key () const
 Get Primary Key value. More...
 
rapidjson::Value get_procedure_items () const
 Add OpenAPI path items for MRS Funcions and Pocedure objects. More...
 

Private Member Functions

rapidjson::Value add_type_constraints (const std::string &type_name, const mrs::database::entry::ColumnType type) const
 Add OpenAPI type constraints based on the MySQL datatype for the given column. More...
 
rapidjson::Value create_parameter (std::string_view name, std::string_view type) const
 Add parameter for entries with Primary Key. More...
 
rapidjson::Value get_filter_parameter (const bool is_required) const
 Add filter parameters to GET and DELETE methods. More...
 
rapidjson::Value get_integer_parameter (const std::string &name) const
 Add 'limit' and 'offset' parameters to GET method. More...
 
rapidjson::Value get_content_schema_array () const
 Create a reference to OpenAPI components section for methods that are returning multiple records. More...
 
rapidjson::Value get_content_schema_single () const
 Create a reference to OpenAPI components section for methods that are returning one record. More...
 
void add_security (rapidjson::Value &method) const
 Add security section if applicable. More...
 
rapidjson::Value get_tag () const
 Tags that are going to be used to distinguish paths. More...
 
std::string column_type_to_openapi (mrs::database::entry::ColumnType type) const
 Map column type to OpenAPI supported types. More...
 
rapidjson::Value get_delete_response () const
 Response for successful DELETE operation. More...
 
rapidjson::Value get_procedure_components () const
 Add OpenAPI component items for MRS Pocedure objects. More...
 
rapidjson::Value get_function_components () const
 Add OpenAPI component items for MRS Funcion objects. More...
 
rapidjson::Value get_procedure_result_example () const
 Get an example of a result set produced by a Procedure call. More...
 
std::optional< rapidjson::Value > get_type_info (const std::string &raw_data_type) const
 

Private Attributes

rapidjson::Document::AllocatorType & allocator_
 
DbObjectPtr entry_
 
const std::string ref_name_
 
const std::string schema_ref_
 
std::optional< std::string > primary_key_
 
rapidjson::Value parameters_ {rapidjson::kArrayType}
 

Detailed Description

Helper class that facilitates generating OpenAPI swagger for the given DBobject entry.

Constructor & Destructor Documentation

◆ OpenApiCreator()

mrs::rest::OpenApiCreator::OpenApiCreator ( DbObjectPtr  entry,
rapidjson::Document::AllocatorType &  allocator 
)
inline

Member Function Documentation

◆ add_security()

void mrs::rest::OpenApiCreator::add_security ( rapidjson::Value &  method) const
private

Add security section if applicable.

◆ add_type_constraints()

rapidjson::Value mrs::rest::OpenApiCreator::add_type_constraints ( const std::string &  type_name,
const mrs::database::entry::ColumnType  type 
) const
private

Add OpenAPI type constraints based on the MySQL datatype for the given column.

◆ column_type_to_openapi()

std::string mrs::rest::OpenApiCreator::column_type_to_openapi ( mrs::database::entry::ColumnType  type) const
private

Map column type to OpenAPI supported types.

◆ create_components()

rapidjson::Value mrs::rest::OpenApiCreator::create_components ( ) const

Create OpenAPI components for the current entry.

◆ create_delete_by_key_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_delete_by_key_method ( ) const

Create HTTP DELETE method contents for OpenAPI path.

Primary key used as a parameter.

◆ create_delete_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_delete_method ( ) const

Create HTTP DELETE method contents for OpenAPI path.

◆ create_get_by_key_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_get_by_key_method ( ) const

Create HTTP GET method contents for OpenAPI path.

Primary key used as a parameter.

◆ create_get_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_get_method ( ) const

Create HTTP GET method contents for OpenAPI path.

◆ create_parameter()

rapidjson::Value mrs::rest::OpenApiCreator::create_parameter ( std::string_view  name,
std::string_view  type 
) const
private

Add parameter for entries with Primary Key.

◆ create_post_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_post_method ( ) const

Create HTTP POST method contents for OpenAPI path.

◆ create_put_method()

rapidjson::Value mrs::rest::OpenApiCreator::create_put_method ( ) const

Create HTTP PUT method contents for OpenAPI path.

◆ get_content_schema_array()

rapidjson::Value mrs::rest::OpenApiCreator::get_content_schema_array ( ) const
private

Create a reference to OpenAPI components section for methods that are returning multiple records.

◆ get_content_schema_single()

rapidjson::Value mrs::rest::OpenApiCreator::get_content_schema_single ( ) const
private

Create a reference to OpenAPI components section for methods that are returning one record.

◆ get_delete_response()

rapidjson::Value mrs::rest::OpenApiCreator::get_delete_response ( ) const
private

Response for successful DELETE operation.

◆ get_filter_parameter()

rapidjson::Value mrs::rest::OpenApiCreator::get_filter_parameter ( const bool  is_required) const
private

Add filter parameters to GET and DELETE methods.

◆ get_function_components()

rapidjson::Value mrs::rest::OpenApiCreator::get_function_components ( ) const
private

Add OpenAPI component items for MRS Funcion objects.

◆ get_integer_parameter()

rapidjson::Value mrs::rest::OpenApiCreator::get_integer_parameter ( const std::string &  name) const
private

Add 'limit' and 'offset' parameters to GET method.

◆ get_procedure_components()

rapidjson::Value mrs::rest::OpenApiCreator::get_procedure_components ( ) const
private

Add OpenAPI component items for MRS Pocedure objects.

◆ get_procedure_items()

rapidjson::Value mrs::rest::OpenApiCreator::get_procedure_items ( ) const

Add OpenAPI path items for MRS Funcions and Pocedure objects.

◆ get_procedure_result_example()

rapidjson::Value mrs::rest::OpenApiCreator::get_procedure_result_example ( ) const
private

Get an example of a result set produced by a Procedure call.

◆ get_tag()

rapidjson::Value mrs::rest::OpenApiCreator::get_tag ( ) const
private

Tags that are going to be used to distinguish paths.

◆ get_type_info()

std::optional< rapidjson::Value > mrs::rest::OpenApiCreator::get_type_info ( const std::string &  raw_data_type) const
private

◆ has_primary_key()

bool mrs::rest::OpenApiCreator::has_primary_key ( ) const
inline

Information if the current entry contain Primary Key configured.

◆ primary_key()

std::string mrs::rest::OpenApiCreator::primary_key ( ) const
inline

Get Primary Key value.

Member Data Documentation

◆ allocator_

rapidjson::Document::AllocatorType& mrs::rest::OpenApiCreator::allocator_
private

◆ entry_

DbObjectPtr mrs::rest::OpenApiCreator::entry_
private

◆ parameters_

rapidjson::Value mrs::rest::OpenApiCreator::parameters_ {rapidjson::kArrayType}
private

◆ primary_key_

std::optional<std::string> mrs::rest::OpenApiCreator::primary_key_
private

◆ ref_name_

const std::string mrs::rest::OpenApiCreator::ref_name_
private

◆ schema_ref_

const std::string mrs::rest::OpenApiCreator::schema_ref_
private

The documentation for this class was generated from the following file: