Papupata Documentation

API Reference

class APIDeclaration

import {APIDeclaration} from 'papupata'

Purpose

Used for declaring, implementing and calling APIs

Usage

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

NameDefault valueDescription
RequestTypeRequest (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.
RouteOptionsvoidIf you want to pass options to your route definitions, then this type defines the type for them.
RequestOptionsvoidIf you want to pass options when making requests, then this type defines the type for them.

Members

NameTypeData type/return typeDescriptionIntroduced in
configuremethodvoidConfigures papupata to allow implementing and/or calling the declared APIs.
getConfigmethodConfigurationReturns the current configuration
getDeclaredAPIsmethodDeclaredAPI[]Returns an array of all APIs declared on this API declaration.1.4.0
declareDeleteAPImethodPartiallyDeclaredAPIDeclares an API using the DELETE HTTP method.
declareGetAPImethodPartiallyDeclaredAPIDeclares an API using the GET HTTP method.
declarePatchAPImethodPartiallyDeclaredAPIDeclares an API using the PATCH HTTP method.1.5.0
declarePostAPImethodPartiallyDeclaredAPIDeclares an API using the POST HTTP method.
declarePutAPImethodPartiallyDeclaredAPIDeclares an API using the PUT HTTP method.
unmockAllmethodvoidUndoes all mocks on the APIs of this API declaration1.1.0
updateConfigmethodvoidUpdates parts of the configuration without affecting the rest of it.2.0.0