Skip to content

Swagger

@aeternity/aepp-sdk/es/utils/swagger

Swagger module

Example

import Swagger from '@aeternity/aepp-sdk/es/utils/swagger'

Swagger(options) ⇒ Object

Swagger Stamp

Kind: Exported function
Returns: Object - Account instance
rtype: Stamp

Param Type Description
options Object Initializer object
options.swag Object Swagger definition
options.axiosConfig Object Object with axios configuration. Example { config: {}, errorHandler: (err) => throw err }

Example

Swagger({swag})

Swagger.expandPath(s) ⇒ String

Perform path string interpolation

Kind: static method of Swagger
Returns: String - Converted string
rtype: (path: String, replacements: Object) => String

Param Type Description
s String String to convert

Swagger.conform(value, spec, types) ⇒ Object

Conform value against its spec

Kind: static method of Swagger
Returns: Object - Conformed value
rtype: (value: Any, spec: Object, types: Object) => Any, throws: Error

Param Type Description
value Object Value to conform (validate and transform)
spec Object Specification object
types Object Types specification

Swagger.traverseKeys(fn, o) ⇒ Object

Key traversal metafunction

Kind: static method of Swagger
Returns: Object - Transformed object
rtype: (fn: (s: String) => String) => (o: Object) => Object

Param Type Description
fn function Key transformation function
o Object Object to traverse

Swagger.snakizeKeys(o) ⇒ Object

snake_case key traversal

Kind: static method of Swagger
Returns: Object - Transformed object
rtype: (o: Object) => Object See: pascalToSnake

Param Type Description
o Object Object to traverse

Swagger.pascalizeKeys(o) ⇒ Object

PascalCase key traversal

Kind: static method of Swagger
Returns: Object - Transformed object
rtype: (o: Object) => Object See: snakeToPascal

Param Type Description
o Object Object to traverse

Swagger.assertOne(coll) ⇒ Object

Assert that coll is a sequence with a length of 1 and extract the only element

Kind: static method of Swagger
rtype: (coll: [...Any]) => Any, throws: Error

Param Type
coll Array.<Object>

Swagger.operation(path, method, definition, types) ⇒ function

Generate callable operation

Kind: static method of Swagger
rtype: (path: String, method: String, definition: Object, types: Object) => (instance: Swagger, url: String) => Promise[Any], throws: Error

Param Type Description
path String Path to call in URL
method String HTTP method
definition Object Complex definition
types Object Swagger types

Swagger.debugSwagger(bool) ⇒ Stamp

Reconfigure Swagger to (not) spill debugging logs

Kind: static method of Swagger
Returns: Stamp - Reconfigured Swagger Stamp
rtype: (bool: Boolean) => Stamp

Param Type Description
bool boolean Whether to debug

Swagger~conformTypes

Per-type conform dispatcher

Kind: inner constant of Swagger
rtype: [(dispatch(value: String, spec: Object, types: Object) => Any, throws: Error)...]

Swagger~lookupType(path, spec, types) ⇒ Object

Lookup type

Kind: inner method of Swagger
Returns: Object - Looked up type definition
rtype: (path: [String...], spec: Object, types: Object) => Object

Param Type Description
path Array.<String> Path to look up
spec Object
types Object

Swagger~extendingErrorPath(key, fn) ⇒ Any

Intercept errors thrown by fn(), extending them with information from key

Kind: inner method of Swagger
Returns: Any - Execution result
rtype: (key: String, fn: Function) => Any

Param Type Description
key String Information to attach
fn function Thunk

Swagger~TypeError(msg, spec, value) ⇒ Error

Construct Error with additional type information (not thrown)

Kind: inner method of Swagger
Returns: Error - Enhanced Error
rtype: (msg: String, spec: String, value: String) => Error

Param Type Description
msg String Error message
spec String
value String

Swagger~conformDispatch(spec) ⇒ String

conform dispatcher

Kind: inner method of Swagger
Returns: String - Value to dispatch on
rtype: (spec: Object) => String, throws: Error

Param Type
spec Object

Swagger~classifyParameters(parameters) ⇒ Array.<Object>

Classify given parameters

Kind: inner method of Swagger
Returns: Array.<Object> - Classified parameters
rtype: (parameters: [{required: Boolean, in: String}...]) => {pathArgs: [...Object], queryArgs: [...Object], bodyArgs: [...Object], req: [...Object], opts: [...Object]}

Param Type Description
parameters Array.<Object> Parameters to classify

Swagger~pascalizeParameters(parameters) ⇒ Array.<Object>

Convert name attributes in parameters from snake_case to PascalCase

Kind: inner method of Swagger
Returns: Array.<Object> - Pascalized parameters
rtype: (parameters: [{name: String}...]) => [{name: String}...]

Param Type Description
parameters Array.<Object> Parameters to pascalize

Swagger~operationSignature(name, req, opts) ⇒ String

Obtain readable signature for operation

Kind: inner method of Swagger
Returns: String - Signature
rtype: (name: String, req: [...Object], opts: [...Object]) => Object

Param Type Description
name String Name of operation
req Array.<Object> Required parameters to operation
opts Array.<Object> Optional parameters to operation

Swagger~destructureClientError(error) ⇒ String

Destructure HTTP client error

Kind: inner method of Swagger
rtype: (error: Error) => String

Param Type
error Error

Swagger~resolveRef(ref, swag) ⇒ Object

Resolve reference

Kind: inner method of Swagger
Returns: Object - Resolved reference definition
rtype: (ref: String, swag: Object) => Object

Param Type Description
ref String Reference to resolve
swag Object