Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Latest commit

 

History

History
160 lines (118 loc) · 4.7 KB

utilities.md

File metadata and controls

160 lines (118 loc) · 4.7 KB

Functions

getSuccessResponse(operation)

Returns the response for either 200 or 201 response codes.

translate(obj, spec, references)

Translates a value into a lookup table.

resolveReference(obj, spec, references)

Resolves references to other objects in the spec or external specs.

getReferenceName($ref)

Returns the last section of a JSON reference path.

extractModelName($ref)

Extracts the model name from a JSON reference path.

getMimeType(array)

Retreives the first mime type of a consumes or produces array.

sortKeys(object)

Recreates an object with the keys sorted by their name (case insensitive).

capitalize(string)

Capitalizes a string

uncapitalize(string)

Uncapitalizes a string

random(low, high)

Generates a random number within a given range

getSuccessResponse(operation) ⇒

Returns the response for either 200 or 201 response codes.

Kind: global function
Returns: the response for 200 or 201 if found, null otherwise

Param Type Description
operation object The operation object

translate(obj, spec, references) ⇒

Translates a value into a lookup table.

Kind: global function
Returns: the translated value if found, otherwise the defaultValue if specified, or input value.

Param Type Description
obj object The current reference object to resolve
spec object The current specification object
references object The references lookup object

resolveReference(obj, spec, references) ⇒

Resolves references to other objects in the spec or external specs.

Kind: global function
Returns: the object that contains the referenced object and spec.

Param Type Description
obj object The current reference object to resolve
spec object The current specification object
references object The references lookup object

getReferenceName($ref) ⇒

Returns the last section of a JSON reference path.

Kind: global function
Returns: the referenced object's name

Param Type Description
$ref object The reference path value

extractModelName($ref) ⇒

Extracts the model name from a JSON reference path.

Kind: global function
Returns: the referenced object's model name

Param Type Description
$ref object The reference path value

getMimeType(array) ⇒

Retreives the first mime type of a consumes or produces array.

Kind: global function
Returns: mime type if the array is populated, a default mime type otherwise

Param Type Description
array Array.<string> The consumes or produces array

sortKeys(object) ⇒

Recreates an object with the keys sorted by their name (case insensitive).

Kind: global function
Returns: a new object with sorted keys

Param Type Description
object object The object to sort

capitalize(string) ⇒

Capitalizes a string

Kind: global function
Returns: the capitalized string value

Param Type Description
string string The string to capitalize

uncapitalize(string) ⇒

Uncapitalizes a string

Kind: global function
Returns: the uncapitalized string value

Param Type Description
string string The string to uncapitalize

random(low, high) ⇒

Generates a random number within a given range

Kind: global function
Returns: the randomly generated number

Param Type Description
low number The minimum value
high number The maximum value