# Model.hpp

This File On Github
Ask A Question

API: latest
module: oatpp-swagger
#include "oatpp-swagger/Model.hpp"

This is the general model for swagger info. It is used as a base model to generate API info for a particular API specification. Ex. for OAS3

# Contact


namespace oatpp { namespace swagger { 
  struct Contact {}

# Fields

Type Name Summary
String name name.
String url url.
String email email.

# Methods

Return Type Name Summary
std::shared_ptr<Contact> createShared Create shared Contact.

# Contact::name


String name

# Contact::url


String url

# Contact::email


String email

# Contact::createShared

Create shared Contact.

  • @return - 'std::shared_ptr' to Contact.

static std::shared_ptr<Contact> createShared()

# License


namespace oatpp { namespace swagger { 
  struct License {}

# Fields

Type Name Summary
String name name.
String url Url.

# Methods

Return Type Name Summary
std::shared_ptr<License> createShared Create shared License.

# License::name


String name

# License::url


String url

# License::createShared

Create shared License.

  • @return - 'std::shared_ptr' to License.

static std::shared_ptr<License> createShared()

# DocumentHeader

Document Header.

namespace oatpp { namespace swagger { 
  struct DocumentHeader {}

# Fields

Type Name Summary
String title Document title.
String description Document description.
String termsOfService Terms of service.
std::shared_ptr<Contact> contact Contact.
std::shared_ptr<License> license License.
String version Version.

# Methods

Return Type Name Summary
std::shared_ptr<DocumentHeader> createShared Create shared DocumentHeader.

# DocumentHeader::title

Document title.

String title

# DocumentHeader::description

Document description.

String description

# DocumentHeader::termsOfService

Terms of service.

String termsOfService

# DocumentHeader::contact


std::shared_ptr<Contact> contact

# DocumentHeader::license


std::shared_ptr<License> license

# DocumentHeader::version


String version

# DocumentHeader::createShared

Create shared DocumentHeader.

  • @return - 'std::shared_ptr' to DocumentHeader.

static std::shared_ptr<DocumentHeader> createShared()

# ServerVariable

Server variable.

namespace oatpp { namespace swagger { 
  struct ServerVariable {}

# Fields

Type Name Summary
String description Description.
std::shared_ptr<std::list<String>> enumValues Enum values.
String defaultValue Default value.

# Methods

Return Type Name Summary
std::shared_ptr<ServerVariable> createShared Create shared ServerVariable.

# ServerVariable::description


String description

# ServerVariable::enumValues

Enum values.

std::shared_ptr<std::list<String>> enumValues

# ServerVariable::defaultValue

Default value.

String defaultValue

# ServerVariable::createShared

Create shared ServerVariable.

  • @return - 'std::shared_ptr' to ServerVariable.

static std::shared_ptr<ServerVariable> createShared()

# Server


namespace oatpp { namespace swagger { 
  struct Server {}

# Fields

Type Name Summary
String url Url.
String description Description.
std::shared_ptr<std::unordered_map<String, std::shared_ptr<ServerVariable>>> variables Variables.

# Methods

Return Type Name Summary
std::shared_ptr<Server> createShared Create shared Server.

# Server::url


String url

# Server::description


String description

# Server::variables


std::shared_ptr<std::unordered_map<String, std::shared_ptr<ServerVariable>>> variables

# Server::createShared

Create shared Server.

  • @return - 'std::shared_ptr' to Server.

static std::shared_ptr<Server> createShared()

# OAuthFlow

OAuth flow Object https://swagger.io/specification/#oauthFlowObject

namespace oatpp { namespace swagger { 
  struct OAuthFlow {}

# Fields

Type Name Summary
oatpp::String authorizationUrl Authorization Url
oatpp::String tokenUrl Token Url
oatpp::String refreshUrl Refresh Url
std::shared_ptr<std::unordered_map<String, String>> scopes Scopes

# OAuthFlow::authorizationUrl

Authorization Url

oatpp::String authorizationUrl

# OAuthFlow::tokenUrl

Token Url

oatpp::String tokenUrl

# OAuthFlow::refreshUrl

Refresh Url

oatpp::String refreshUrl

# OAuthFlow::scopes


std::shared_ptr<std::unordered_map<String, String>> scopes

# OAuthFlows

OAuth Flows Object https://swagger.io/specification/#oauthFlowObject

namespace oatpp { namespace swagger { 
  struct OAuthFlows {}

# Fields

Type Name Summary
std::shared_ptr<OAuthFlow> implicit Implicit
std::shared_ptr<OAuthFlow> password Password
std::shared_ptr<OAuthFlow> clientCredentials Client Credentials
std::shared_ptr<OAuthFlow> authorizationCode Authorization Code

# OAuthFlows::implicit


std::shared_ptr<OAuthFlow> implicit

# OAuthFlows::password


std::shared_ptr<OAuthFlow> password

# OAuthFlows::clientCredentials

Client Credentials

std::shared_ptr<OAuthFlow> clientCredentials

# OAuthFlows::authorizationCode

Authorization Code

std::shared_ptr<OAuthFlow> authorizationCode

# SecurityScheme

Security Scheme object - https://swagger.io/specification/#securitySchemeObject .

namespace oatpp { namespace swagger { 
  struct SecurityScheme {}

# Fields

Type Name Summary
oatpp::String type Type
oatpp::String description Description
oatpp::String name Name
oatpp::String in In
oatpp::String scheme Scheme
oatpp::String bearerFormat Bearer Format.
std::shared_ptr<OAuthFlows> flows Flows.
oatpp::String openIdConnectUrl Open Id Connect Url.

# SecurityScheme::type


oatpp::String type

# SecurityScheme::description


oatpp::String description

# SecurityScheme::name


oatpp::String name

# SecurityScheme::in


oatpp::String in

# SecurityScheme::scheme


oatpp::String scheme

# SecurityScheme::bearerFormat

Bearer Format.

oatpp::String bearerFormat

# SecurityScheme::flows


std::shared_ptr<OAuthFlows> flows

# SecurityScheme::openIdConnectUrl

Open Id Connect Url.

oatpp::String openIdConnectUrl

# DocumentInfo

Document Info.

namespace oatpp { namespace swagger { 
  class DocumentInfo {}

# Fields

Type Name Summary
std::shared_ptr<DocumentHeader> header DocumentHeader.
std::shared_ptr<std::list<std::shared_ptr<Server>>> servers List of Server.
std::shared_ptr<std::unordered_map<oatpp::String, std::shared_ptr<SecurityScheme>>> securitySchemes Map of oatpp::String to SecurityScheme.

# Methods

Return Type Name Summary
std::shared_ptr<DocumentInfo> createShared Create shared DocumentInfo.

# DocumentInfo::header


std::shared_ptr<DocumentHeader> header

# DocumentInfo::servers

List of Server.

std::shared_ptr<std::list<std::shared_ptr<Server>>> servers

# DocumentInfo::securitySchemes

Map of oatpp::String to SecurityScheme.

std::shared_ptr<std::unordered_map<oatpp::String, std::shared_ptr<SecurityScheme>>> securitySchemes

# DocumentInfo::createShared

Create shared DocumentInfo.

  • @return - 'std::shared_ptr' to DocumentInfo.

static std::shared_ptr<DocumentInfo> createShared()

# DocumentInfo::SecuritySchemeBuilder

SecurityScheme Builder.

namespace oatpp { namespace swagger { 
  class DocumentInfo {
    class SecuritySchemeBuilder {}

# Methods

Return Type Name Summary
std::shared_ptr<SecurityScheme> DefaultBasicAuthorizationSecurityScheme Convenience default Basic-Authorization SecurityScheme.
std::shared_ptr<SecurityScheme> DefaultBearerAuthorizationSecurityScheme Convenience default Bearer-Authorization SecurityScheme.
SecuritySchemeBuilder& setType Set type.
SecuritySchemeBuilder& setDescription Set description.
SecuritySchemeBuilder& setName Set name.
SecuritySchemeBuilder& setIn Set 'in'.
SecuritySchemeBuilder& setScheme Set scheme.
SecuritySchemeBuilder& setBearerFormat Set bearer format.
SecuritySchemeBuilder& setImplicitFlow Set implicit flow.
SecuritySchemeBuilder& setPasswordFlow Set password flow.
SecuritySchemeBuilder& setClientCredentialsFlow Set client credentials flow.
SecuritySchemeBuilder& setAuthorizationCodeFlow Set authorization code flow.
SecuritySchemeBuilder& setOpenIdConnectUrl Set open id connect url.
std::shared_ptr<SecurityScheme> build Build SecurityScheme.

# DocumentInfo::SecuritySchemeBuilder::DefaultBasicAuthorizationSecurityScheme

Convenience default Basic-Authorization SecurityScheme.

static std::shared_ptr<SecurityScheme> DefaultBasicAuthorizationSecurityScheme()

# DocumentInfo::SecuritySchemeBuilder::DefaultBearerAuthorizationSecurityScheme

Convenience default Bearer-Authorization SecurityScheme.

  • @param bearerFormat - for documentation purposes.
  • @return - SecurityScheme.

static std::shared_ptr<SecurityScheme> DefaultBearerAuthorizationSecurityScheme(const oatpp::String& bearerFormat = nullptr)

# DocumentInfo::SecuritySchemeBuilder::setType

Set type.

  • @param type
  • @return

SecuritySchemeBuilder& setType(const String& type)

# DocumentInfo::SecuritySchemeBuilder::setDescription

Set description.

  • @param description
  • @return

SecuritySchemeBuilder& setDescription(const String& description)

# DocumentInfo::SecuritySchemeBuilder::setName

Set name.

  • @param name
  • @return

SecuritySchemeBuilder& setName(const String& name)

# DocumentInfo::SecuritySchemeBuilder::setIn

Set 'in'.

  • @param in
  • @return

SecuritySchemeBuilder& setIn(const String& in)

# DocumentInfo::SecuritySchemeBuilder::setScheme

Set scheme.

  • @param scheme
  • @return

SecuritySchemeBuilder& setScheme(const String& scheme)

# DocumentInfo::SecuritySchemeBuilder::setBearerFormat

Set bearer format.

  • @param bearerFormat
  • @return

SecuritySchemeBuilder& setBearerFormat(const String& bearerFormat)

# DocumentInfo::SecuritySchemeBuilder::setImplicitFlow

Set implicit flow.

SecuritySchemeBuilder& setImplicitFlow(const std::shared_ptr<OAuthFlow>& flow)

# DocumentInfo::SecuritySchemeBuilder::setPasswordFlow

Set password flow.

SecuritySchemeBuilder& setPasswordFlow(const std::shared_ptr<OAuthFlow>& flow)

# DocumentInfo::SecuritySchemeBuilder::setClientCredentialsFlow

Set client credentials flow.

SecuritySchemeBuilder& setClientCredentialsFlow(const std::shared_ptr<OAuthFlow>& flow)

# DocumentInfo::SecuritySchemeBuilder::setAuthorizationCodeFlow

Set authorization code flow.

SecuritySchemeBuilder& setAuthorizationCodeFlow(const std::shared_ptr<OAuthFlow>& flow)

# DocumentInfo::SecuritySchemeBuilder::setOpenIdConnectUrl

Set open id connect url.

  • @param openIdConnectUrl
  • @return

SecuritySchemeBuilder& setOpenIdConnectUrl(const String& openIdConnectUrl)

# DocumentInfo::SecuritySchemeBuilder::build

Build SecurityScheme.

std::shared_ptr<SecurityScheme> build()

# DocumentInfo::OAuthFlowBuilder

OAuthFlow Builder.

namespace oatpp { namespace swagger { 
  class DocumentInfo {
    class OAuthFlowBuilder {}

# Methods

Return Type Name Summary
OAuthFlowBuilder& setAuthorizationUrl Set authorization url.
OAuthFlowBuilder& setTokenUrl Set token url.
OAuthFlowBuilder& setRefreshUrl Set refresh url.
OAuthFlowBuilder& addScope add scope.
std::shared_ptr<OAuthFlow> build Build OAuthFlow.

# DocumentInfo::OAuthFlowBuilder::setAuthorizationUrl

Set authorization url.

  • @param authorizationUrl
  • @return

OAuthFlowBuilder& setAuthorizationUrl(const String& authorizationUrl)

# DocumentInfo::OAuthFlowBuilder::setTokenUrl

Set token url.

  • @param tokenUrl
  • @return

OAuthFlowBuilder& setTokenUrl(const String& tokenUrl)

# DocumentInfo::OAuthFlowBuilder::setRefreshUrl

Set refresh url.

  • @param refreshUrl
  • @return

OAuthFlowBuilder& setRefreshUrl(const String& refreshUrl)

# DocumentInfo::OAuthFlowBuilder::addScope

add scope.

  • @param name
  • @param scope
  • @return

OAuthFlowBuilder& addScope(const String& name, const String& scope)

# DocumentInfo::OAuthFlowBuilder::build

Build OAuthFlow.

std::shared_ptr<OAuthFlow> build()

# DocumentInfo::Builder

Document Info Builder.

namespace oatpp { namespace swagger { 
  class DocumentInfo {
    class Builder {}

# Methods

Return Type Name Summary
Builder& setTitle Set document title.
Builder& setDescription Set document description.
Builder& setTermsOfService Set terms of service.
Builder& setVersion Set version.
Builder& setContactName Set contact name.
Builder& setContactUrl Set contact url.
Builder& setContactEmail Set contact email.
Builder& setLicenseName Set license name.
Builder& setLicenseUrl Set license url.
Builder& addServer Multiple implementations:
  1. Add Server.
  2. Add Server.
Builder& addSecurityScheme Add SecurityScheme.
std::shared_ptr<DocumentInfo> build Build Document Info.

# DocumentInfo::Builder::setTitle

Set document title.

Builder& setTitle(const oatpp::String& title)

# DocumentInfo::Builder::setDescription

Set document description.

Builder& setDescription(const oatpp::String& description)

# DocumentInfo::Builder::setTermsOfService

Set terms of service.

Builder& setTermsOfService(const oatpp::String& termsOfService)

# DocumentInfo::Builder::setVersion

Set version.

Builder& setVersion(const oatpp::String& version)

# DocumentInfo::Builder::setContactName

Set contact name.

Builder& setContactName(const oatpp::String& name)

# DocumentInfo::Builder::setContactUrl

Set contact url.

Builder& setContactUrl(const oatpp::String& url)

# DocumentInfo::Builder::setContactEmail

Set contact email.

Builder& setContactEmail(const oatpp::String& email)

# DocumentInfo::Builder::setLicenseName

Set license name.

Builder& setLicenseName(const oatpp::String& name)

# DocumentInfo::Builder::setLicenseUrl

Set license url.

Builder& setLicenseUrl(const oatpp::String& url)

# DocumentInfo::Builder::addServer

  1. Add Server.
    Builder& addServer(const std::shared_ptr<Server>& server)
  2. Add Server.
    Builder& addServer(const oatpp::String& url, const oatpp::String& description)

# DocumentInfo::Builder::addSecurityScheme

Add SecurityScheme. When you are using the AUTHENTICATION() Endpoint-Macro you must add an SecurityScheme. For basic-authentication you can use the default oatpp::swagger::DocumentInfo::SecuritySchemeBuilder::DefaultBasicAuthorizationSecurityScheme(). For more complex authentication schemes you can use the oatpp::swagger::DocumentInfo::SecuritySchemeBuilder builder. Don't forget to add info->addSecurityRequirement(name) to your ENDPOINT_INFO() macro!

Builder& addSecurityScheme(const oatpp::String& name, const std::shared_ptr<SecurityScheme> &ss)

# DocumentInfo::Builder::build

Build Document Info.

std::shared_ptr<DocumentInfo> build()