A module that loads and provides the service endpoint descriptors
Members
(static, constant) getAllStaticEndpoints
Get all static endpoints
(static, constant) getAllTestCases
Get all test cases
(static, constant) getImplementation
Get the implementation of a method of a service endpoint
(static, constant) getMockRequestBody
Get the request body of a given method of a service.
The default content type is 'application/json'.
(static, constant) getMockResponseBody
Get the response body of a given method of a service.
The default content type is application/json
.
(static, constant) getRequestHeaders
Get the request headers of a given method of a service.
(static, constant) getResponseHeaders
Get the response headers of a given method of a service.
(static, constant) getServices
Get the services object, that holds the complete set of service descriptors.
(inner) services
Descriptors object, that holds all services and provides details
Methods
(static) load(restapiRoot, servicesRoot) → {Object}
Load all service descriptors
Parameters:
Name | Type | Description |
---|---|---|
restapiRoot |
String | The path to the main config file of the services named: |
servicesRoot |
String | The path to the root folder where the service descriptors are placed. |
Returns:
- The Object, which holds all service descriptors, using the URI patterns as keys.
in case of error returns with
null
.
- Type
- Object
(inner) findHeaderValue(headers, field) → {String}
Finds the actual value of the header field
Parameters:
Name | Type | Description |
---|---|---|
headers |
Array | The array of header descriptor objects |
field |
String | The header field name |
Returns:
- The value of the header field
- Type
- String
(inner) findResponseDesc(method, serviceDesc, nameOfResponse) → {Object}
Find response descriptor of a given method of a service.
Parameters:
Name | Type | Description |
---|---|---|
method |
String | The name of the method, such as GET, PUT, etc. |
serviceDesc |
Object | The service descriptor object |
nameOfResponse |
Object | The name of the response, default: 'OK' |
Returns:
- The response descriptor object or
null
if not found
- Type
- Object
(inner) getMockBody(serviceDesc, mockBodyPath, contentType) → {String}
Get the mock content body of a service.
Parameters:
Name | Type | Description |
---|---|---|
serviceDesc |
Object | The service descriptor object |
mockBodyPath |
String | The filename of the mockBody content. It has to be relative to the directory that holds the service descriptor. |
contentType |
String | The service descriptor object. One of: 'text/plain', 'text/html', 'text/xml', 'application/json'. The default content type is 'application/json'. |
Returns:
- The content of the mock body
- Type
- String
(inner) loadServices(restapiRoot, servicesRoot, servicesToLoad)
Load service descriptor files
Parameters:
Name | Type | Description |
---|---|---|
restapiRoot |
String | |
servicesRoot |
String | |
servicesToLoad |
Object |
(inner) mapOwnProperties(obj, funct)
Maps through each own properties of an object, and calls the given function with it
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The object to map within its own properties. |
funct |
function | The map function with the following signature: |
(inner) mkHeadersMap(headers) → {Opject}
Make a headermap object of a headers descriptor array
Parameters:
Name | Type | Description |
---|---|---|
headers |
Array | The array of the header descriptor objects |
Returns:
- The map of headers in the format it can hand over to express
- Type
- Opject
(inner) setAlias(object, property, alias)
Set alias property to a specific part of a serviceDescriptor object.
It adds a property that will refer to an other property, that the new property is an alias of In case the object has the named alias property yet, then it does not change its value, however it also checks if the original property exists. In case the alias exists but the original does not exists, then it creates a property with the original name, that will refer to the alias property.
Note: The original object will be changed.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | The (sub)-object of the full descriptor |
property |
String | The property name |
alias |
AnyType | The alias property the alias will point |
(inner) setAliases(serviceDescriptor)
Set alias properties to a serviceDescriptor object.
It adds properties in several places of the descriptor and changes the original object.
Note: The original service descriptor object will be changed.
Parameters:
Name | Type | Description |
---|---|---|
serviceDescriptor |
Object | The service descriptor object |
(inner) setDefault(object, property, defaultValue)
Set default value to a specific part of a serviceDescriptor object.
It adds a property with a default value to the descriptor and changes the original object. In case the object has the named property yet, then it does not change its value.
Note: The original object will be changed.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | The (sub)-object of the full descriptor |
property |
String | The property name |
defaultValue |
AnyType | The default value of the property |
(inner) setDefaults(serviceDescriptor)
Set default values to a serviceDescriptor object.
It adds properties in several places of the descriptor and changes the original object.
Note: The original service descriptor object will be changed.
Parameters:
Name | Type | Description |
---|---|---|
serviceDescriptor |
Object | The service descriptor object |
(inner) updateMethodLists(serviceDescriptor)
Create and update the method list property of a service descriptor object.
Creates a methodList
property of the service descriptor, and fills the list with references
to the original method sub-objects. It results a service descriptor, that's methods can be accessed
both via the method name as well as via an element of an array, which holds all the methods.
Note: The original service descriptor object will be changed.
Parameters:
Name | Type | Description |
---|---|---|
serviceDescriptor |
Object | The service descriptor object |