Stereotype Attributes

REST API

Stereotype REST API is to used define a REST API for a Designer service.

Tagged ValueDescriptionAllowed Values

port

Defines the machine port number the service is binding to.any number
Using ports below 1024 may require additional privileges.
 tracePortDefines the shadow port of the service used for tracing.any number (default is service port + 40000)
maxRequestBodySize

Specifies the maximum size of the request in KB (1 KB = 1024 Bytes). This can be used to prevent DoS or similar attacks. When the payload of the service exceeds the given maximum, incoming request are rejected.

any positive integer
0

Accept unlimited requests (default of services compiled with Builder versions < 7.12.0).

20482MB, default if not specified
maxRequestHeaderSize

Specifies the maximum size of the request header in KB (1 KB = 1024 Bytes). This can be used to prevent DoS or similar attacks. When the header payload of the service exceeds the given maximum, incoming request are rejected.

any positive integer
88 KB (default if not specified).
maxParallelConnections

Defines the maximum number of request that can be processed in parallel.

any positive integer
tokenType

Mark the service as to use token authorization. The REST Test Tool (API Management) will then present a field to enter the token and put the value into the HTTP headers. Refer also to tokenHeaderName for more information.

You can use both in a REST service: basic authorization and token authorization, see useBasicAuth.

noneDo not use token authorization.
API KeyUse API key authorization.
tokenHeaderNameDefines the name of the header that will transport the token. This tagged value is only relevant, if token authorization is enabled at all. The token header name will be presented as the name of the header field that can be entered in the Bridge REST Test Tool. Refer also to tokenType for more information.A valid HTTP header name (according to RFC2616/RFC7230).
useBasicAuth

Mark the service as to use basic authentication mechanisms. The REST Test Tool (API Management) will then present fields to enter the credentials and put the values into the HTTP headers.

You can use both in a REST service: basic authorization and token authorization, see tokeType and tokenHeaderName.

trueEnable basic authentication.
falseDisable basic authentication (default).
jsonKeepNulls
When jsonKeepNulls is true, attributes of the REST response object having NULL values will be rendered to the REST response, otherwise they will be left out completely (see also chapter NULL Values).
trueRender attributes with NULL values to the REST response.
falseLeave out attributes with NULL values in the REST response (default).
jsonCompact
When jsonCompact is true, the JSON composer will generate compact JSON, otherwise it will generate pretty JSON.
trueGenerate compact JSON (default).
falseGenerate pretty JSON.
jsonWriteTypeDiscriminator
If jsonCompact is true, the JSON composer will generate xUML type properties ("e2e:type") to the generated JSON. If this option is true, the Runtime will write the original xUML type to the generated JSON in form of "e2e:type": "<name of the original xUML type>" if the type being serialized does not match the expected metadata. This is necessary if you want to convert the generated JSON back to an xUML class using jsonToClass().
trueWrite xUML type discriminator.
falseDo not write xUML type discriminator.


REST Port

Stereotype REST Port is used on a class to mark it as REST port, the root element of a REST service structure.

Tagged ValueDescriptionAllowed Values
pathDefines the path to this rest interface. If empty, the path is derived from the package structure.nonepath of the package structure will be used, e.g. /API/SupportCase/SupportAPI
any valid path stringpath string starting with "/", e.g. /support
errorClassAssigns a user-defined RESTError class to the REST interface. This class should be set in case of error and given back via the REST response.
For more information on REST error classes, see RESTError.
any complex type describing the structure of the error
apiVersionDefines the API version this port type provides (for documentation purposes only).any string

REST Resource

Stereotype REST Resource is used on a class to mark it as REST resource, part of a REST service structure.

Attribute
(Name of Setting)
DescriptionAllowed Values
Relative Path
(relativePath)
Defines the path of the REST resource or collection in relation to the parent resource. You can provide a static path, or a dynamic path using the notation :<name of a REST Parameter>. You may also provide a combination of both.nonethe name of the REST resource will be used, e.g. /supportcases
any valid stringthe given name will be used
a dynamic path supplying a REST parameterdynamic path, the value of the REST parameter will be passed to the REST methods, e.g. :id
Is Verbatim Path
(isVerbatimPath)

Disable most of the path normalization. All escaping must be done manually, leading or trailing whitespaces are preserved.
This is what still will be done, if isVerbatimPath is set to true:

  • variable discovery
    The xUML Runtime will try to find and replace variables (:<my variable name>).
  • colon escaping
    If the path contains a colon that (and that does not indicate a path parameter), you can escape this colon by another one, like :: (e.g. /myAPI/resource/aText::anotherText/:variable).
  • correction of segment delimiters
    The xUML Compiler adds a leading slash (if not present), removes trailing slashes (if present) and removes duplicates slashes, e.g. myAPI//resource/:variable/ becomes /myAPI/resource/:variable.
truePath should be treated as verbatim, path normalization is disabled.
false (default)Path should be URL encoded.

REST

Stereotype REST is used on a REST resource class method to mark it as REST method, part of a REST service structure. If the method name is one of GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS (with optional trailing '/'), it will be invoked automatically on its parent resource when an corresponding request is received.

Refer Implementing REST Methods to for more details and some examples.

Attribute
(Name of Setting)
DescriptionAllowed Values
Http Method
(httpMethod)

Provide the HTTP method of this REST method should respond to.

a valid HTTP methodGET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
none
  • method name, if it is one of: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS (with optional trailing '/')
  • GET otherwise
Relative Path
(relativePath)
Defines the path of the REST method in relation to the parent resource.noneThe name of the REST method will be used.
any valid stringThe given name will be used. The relative path may also contain variables (REST path parameters, specified as :<variable name>) and can be segmented like e.g. /date=:<a date variable> .
Is Verbatim Path
(isVerbatimPath)

Disable most of the path normalization. All escaping must be done manually, leading or trailing whitespaces are preserved.
This is what still will be done, if isVerbatimPath is set to true:

  • variable discovery
    The xUML Runtime will try to find and replace variables (:<my variable name>).
  • colon escaping
    If the path contains a colon that (and that does not indicate a path parameter), you can escape this colon by another one, like :: (e.g. /myAPI/resource/aText::anotherText/:variable).
  • correction of segment delimiters
    The xUML Compiler adds a leading slash (if not present), removes trailing slashes (if present) and removes duplicates slashes, e.g. myAPI//resource/:variable/ becomes /myAPI/resource/:variable.
truePath should be treated as verbatim, path normalization is disabled.
false (default)Path should be URL encoded.
Blob Body Content Type
(blobBodyContentType)

Specify a content type for Blob response parameters from this endpoint. This must be a valid "accept" header as defined in RFC 7231.
Refer to Handling Blobs in the REST Interface for a deeper explanation and some examples.

This attribute must be left unset if no Blob output parameters are used. In future versions, the effect of this attribute may be extended to other contexts as well.

a list of valid media rangese.g. image/png
Default is application/octet-stream if not specified.
Reject Other Response Content Types
(rejectOtherResponseContentTypes)

The xUML Runtime performs a verification of the "accept" header for REST responses. Specify whether to return an error (HTTP 406, not acceptable) on requests with an "accept" header that does not conform with the content types specified in Blob Body Content Type.
Refer to Handling Blobs in the REST Interface for a deeper explanation and some examples.


true
  • Reject calls to the endpoint if the "accept" header does not match the values listed in Blob Body Content Type (default).
  • Exception: HTTP 406 (Not acceptable)
    This exception can be suppressed by setting Ignore Http Errors to true on the REST adapter alias.
falseAccept the request in spite of the mismatch and handle this within the service.
Accepted Request Content Types
(acceptedRequestContentType)

Provide a list of content types this REST endpoint accepts. This must be a list of valid "accept" headers as defined in RFC 7231.
Refer to Handling Blobs in the REST Interface for a deeper explanation and some examples.

This attribute must be left unset if no Blob output parameters are used. In future versions, the effect of this attribute may be extended to other contexts as well.

a list of valid media rangese.g. image/png;image/jpeg
Default is application/octet-stream if not specified.
Reject Other Request Content Types
(rejectOtherRequestContentTypes)

Specify whether to return an error on requests with a content type that does not conform with the content types specified in Accepted Request Content Type.
Refer to Handling Blobs in the REST Interface for a deeper explanation and some examples.

true
  • Reject calls to this endpoint if the "content-type" header does not match the values listed in Accepted Request Content Type (default).
  • Exception: HTTP 415 (Unsupported Media Type)
    This exception can be suppressed by setting Ignore Http Errors to true on the REST adapter alias.
falsePerform the adapter call in spite of the "content-type" header mismatch and handle this within the service.

REST Parameter

Stereotype REST Parameter is used on a REST method parameter to mark it as REST parameter. Refer to REST Parameters to for more details and some examples.

Tagged ValueDescriptionAllowed ValuesAllowed REST MethodsAllowed TypesHints and Limitations
In
(in)
Defines how the parameter will be passed to the REST method. This tag is mandatory.queryvia a query stringallall simple types and Array of simple typeUnknown parameters will be ignored, known will be passed to the method after being URL-decoded.
pathvia the REST resource pathallInteger, Float, String, Boolean, DateTimePath parameters are all required. All path parameters must be consumed by the called method and the parameter names must be the same as the path segment identifiers (without colon).
bodyvia the REST call bodyPOST, PUT, PATCHa complex type and ArrayA REST method can have only one body parameter.
headervia the REST call headerallall simple types and Array of simple typeUnknown parameters will be ignored, known will be passed to the method.
External Name
(externalName)
Defines an external name for the REST parameterany stringUse this, when wanting to access a REST service that has parameter names with special characters. In this case, set this name (e.g. ugly@parameter-name) to externalName and give a better name. So you will not have to escape the parameter every time you use it.

REST Error

Stereotype REST Error is used on a class to mark it as REST error class. Assign such a class to the REST port (see REST Port) and this class will be used as output in case of error. Each REST port can have its separate error class.
You can report errors back to the caller using something like:

local response = getRestHttpResponse();
response.responseObject = <my error object>;
response.httpStatus = <a matching http error code>;

REST Content Types

The xUML Runtime handles content types as follows:

Content Type HeaderAccept HeaderRuntime BehaviorAssumed Content TypeHTTP Header Code
(if content not matching)
(tick)(tick) / (error)

If the Content-Type header is set, the xUML Runtime will assume that the request is of that type. All other request will be rejected (HTTP error code 406).

Content-Type header406
(error)(tick)

If no Content-Type header is set, but the Accept header is, the xUML Runtime will deduce the request type from it. All other request will be rejected (HTTP error code 406).
To determine the format, the Runtime will take into account the quality factor and the order of the accept headers list.

Accept header406
(error)(error)

In absence of both headers, the Runtime will assume JSON. All other request will be rejected (HTTP error code 415).

JSON415

The full matching is done in a "best effort" manner. Given the type format <type>/<subtype>[+<suffix>][; paramName=paramValue]*, the xUML Runtime first disregards the type and parameters. Then it checks, if the subtype is JSON or XML. If the subtype doesn't match with the supported types, it tries the suffix.

REST Adapter Parameters

NameTypeDirectionDescription
requestOptionsRequestOptionsinUse this parameter to configure the REST Adapter dynamically and overwrite the settings from the component diagram.
responseAnyoutThis parameter holds the adapter output and is of that type that is given back by the called REST service.

REST Utility Functions

Access to HTTP request and response objects is provided through global methods: getRestHttpRequest()and getRestHttpResponse().

FunctionParameterReturn ValueDescriptionExample
getRestHttpRequest()noneobject of type RequestReturns the request details as provided by the HTTP call. Changing the request object will not have any effects.
local request = getRestHttpRequest();
getRestHttpResponse()noneobject of type ResponseSet the response details to return them to the caller.
local response = getRestHttpResponse();

getRestHttpRequest() returns the headers in REST service context. In other contexts, e.g. if called via a SOAP shadow port (and thus  SOAP context), getRestHttpRequest() will return NULL. Use  getServiceContext() or getServiceContextValue() in such cases.

REST Parameter Types

Request

AttributeTypeDescriptionValues/Example
methodHTTPMethodHTTP method used in call.GET
queryStringStringQuery string, if provided with the call.status=in%20progress
queryParametersArray of ParameterAll query parameters as an array of Parameter classes containing name/value pairs.
bodyBlobBody of the HTTP request.
pathStringPath to the REST resource./support/supportcases/
pathParametersMapAll REST parameters as a map.
httpHeaderMapMap of Entry

Header information as a map. The map contains arrays of header value strings whereas the header name is the key of the map.

  • Header names are lowercase and treated case insensitive.
  • Multiple headers with the same name are treated as arrays.

Refer to HTTP Header Support for more information on the standard xUML HTTP headers.


Response

AttributeTypeDescriptionValues/Example
headersArray of HeaderFieldAll HTTP response header fields as an array of HeaderField classes containing name/value pairs.
statusCodeIntegerThe resulting HTTP status code. If not set explicitly using this object, the service returns 200 if no exception occurred, or 500 otherwise.404
errorObjectAnyObject of the type defined with stereotype RESTError.

RequestOptions

AttributeTypeDescriptionValues/Example
additionalHeadersArray of HeaderFieldAll REST request header fields as an array of HeaderField classes containing name/value pairs.
optionsArray of Option

Specify native cURL options as listed in Setting cURL Options on the URL Adapter.

Use one of the following syntax rules:

  • values separated by ',' in one line
  • values separated by ' ' in one line
  • list of tagged values

sslSSLUse this parameter to supply SSL information.
proxyProxyUse this parameter to supply necessary proxy information.
additionalQueryParametersArray of ParameterUse this parameter to provide additional query parameters to the REST service call.
followRedirectsIntegerSpecify here the maximum number of redirects to follow.any integer
basicAuthAuthenticationThis parameter provides an object of type Authentication containing the user and the password.
basePathStringOverwrite here the base path of the REST service.a valid path, e.g. /support
hostStringOverwrite here the host running the REST service that has been defined in the component diagram.
portIntegerOverwrite here the port through which the REST service is accessible.
protocolStringOverwrite here the protocol through which the REST service is accessible.http, https
ignoreHttpErrorsBooleanIf true, HTTP error codes >= 400 will not cause an exception in the model. This implies, that the response body is accessible even if HTTP errors occur. Default value is true.true / false
jsonComposerOptionsComposerOptionsUse this parameter to specify JSON composer options on the REST call. You can use these options to e.g. overwrite jsonKeepNulls from the REST alias.

AdapterResponse

AttributeTypeDescriptionValues/Example
httpStatusIntegerHTTP status code of the adapter call.500
headersArray of Header Field

DeprecatedThis attribute is deprecated. It is only present for compatibility reasons.

Please use httpHeaderMap (see below) for new implementations. The implementation of httpHeaderMap complies to the HTTP specification and supports multiple headers having the same name.


bodyBlobHTTP body of HTTP response.
responseObjectAny

Response Object of the REST adapter call.

  • If the adapter had an error, the responseObject is an RESTError class. It could be the default error class or a specific error class dependent on the RESTResponseDefinition dependencies and the HTTP status code.
  • If the adapter call had no error, the responseObject is the same as the response output parameter.

httpHeaderMapMap of Entry

Header information as a map. The map contains arrays of header value strings whereas the header name is the key of the map.

  • Header names are lowercase and treated case insensitive.
  • Multiple headers with the same name are treated as arrays.

Refer to HTTP Header Support for more information on the standard xUML HTTP headers.


Request and Response Types

REST TypeAttributeTypeDescriptionValues/Example
AuthenticationusernameStringUsername.
passwordStringPassword.
CertificatefileStringCertificate file.
typeString

ComposerOptionskeepNullsBooleanKeep NULL values during JSON composing.
EntrykeyStringKey of the map entry.
valueArray of AnyList of values of the map entry. The dynamic type for httpHeaderMap is String.
HTTPMethod
enumerationList of all valid HTTP methodsDELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
HeaderFieldnameStringName of the header field.
valueStringValue of the header field.
OptionnameStringName of the option.
valueStringValue of the option.
ParameternameStringName of the parameter.
valueStringValue of the Parameter.
ProxyurlStringURL.A valid URL.
typeString

authenticationAuthenticationSee above.
SSLverifyPeerString

verifyHostString

caInfoString

certificateCertificateSee above.
keyKey

On this Page:

RESTAPI_SupportManager_Example

Click the icon to download a simple example model that shows the implementation of a REST API with Scheer PAS Designer.

RESTAPI_BlobContent_Example

Click the icon to download a simple example model that shows the implementation of a REST API that receives and returns Blob content with Scheer PAS Designer.

  • No labels