API Reference
class APIDeclaration
import {APIDeclaration} from 'papupata'
Purpose
Used for declaring, implementing and calling APIsUsage
Once created, APIs can be declared using most of the methods. Before implemting or calling the APIs the object must be configured using its configure method.
APIDeclaration has an expicit type parameter, which can be used to override the type of the request used in the API implementations. It defaults to express request.
Type parameeters
Parameters
Name | Default value | Description |
---|---|---|
RequestType | Request (express) | This type parameter is used to set up the type for the request object for implementing the routes with express. The default value should be fine for simple cases, but if you have a custom request type you can use it instead. |
RouteOptions | void | If you want to pass options to your route definitions, then this type defines the type for them. |
RequestOptions | void | If you want to pass options when making requests, then this type defines the type for them. |
Members
Name | Type | Data type/return type | Description | Introduced in |
---|---|---|---|---|
configure | method | void | Configures papupata to allow implementing and/or calling the declared APIs. | |
getConfig | method | Configuration | Returns the current configuration | |
getDeclaredAPIs | method | DeclaredAPI[] | Returns an array of all APIs declared on this API declaration. | 1.4.0 |
declareDeleteAPI | method | PartiallyDeclaredAPI | Declares an API using the DELETE HTTP method. | |
declareGetAPI | method | PartiallyDeclaredAPI | Declares an API using the GET HTTP method. | |
declarePatchAPI | method | PartiallyDeclaredAPI | Declares an API using the PATCH HTTP method. | 1.5.0 |
declarePostAPI | method | PartiallyDeclaredAPI | Declares an API using the POST HTTP method. | |
declarePutAPI | method | PartiallyDeclaredAPI | Declares an API using the PUT HTTP method. | |
unmockAll | method | void | Undoes all mocks on the APIs of this API declaration | 1.1.0 |
updateConfig | method | void | Updates parts of the configuration without affecting the rest of it. | 2.0.0 |