This Snippet shows you how to create a automatic Documentation and Validation of your API. All posible Values are displayed. *IMPORTANT* Change your project from "Web service" to "API" for the API top work and generate Docs. Any Questions? Join the Autocode discord or DM Chillihero#0001 on Discord!
/**
* A Basic API with all kinds of Parameters.
* More Documentation can be found here https://github.com/acode/FunctionScript#parameters
* Some infos:
* ? makes the parameter optional with default parameter `null`
* you can add a default value to a parameter inside the () of module exports, you see a example below
* @param {any} anything Anything can be guven as value LOL (1 | "abc", true | [])
* @param {?any} anything_optional !OPTIONAL Anything can be guven as value LOL (1 | "abc", true | [])
* @param {string} string This is a normal String as Parameter ("Any String")
* @param {boolean} boolean This is a Boolean as Parameter (true/false | t/f | "true"/"false")
* @param {number} number This is a Number as a Parameter (1 | -1 | 1.23432 | 2e+100)
* @param {float} float This is a Float as a Parameter, its basically a alias for float (1 | -1 | 1.23432 | 2e+100)
* @param {integer} integer This is a Integer as a Parameter (1 | -1 | 1000 | 2e+100)
* @param {object.http} object_http An object representing an HTTP Response. Accepts headers, body and statusCode keys
* @param {buffer} buffer Buffer Data representing a file
* @param {enum} enumerated A Enum Parameter with preset Values
* ["USER", 0]
* ["ADMIN", 1]
* @param {array} array This is a Array as a Parameter ([])
* @ {integer} array from integers
* @param {object} object This is a Object as a Parameter ({})
* @ {number} ID This is a number parameter ID of an Object in the response Object
* @ {string} Name This is a stringparameter Name of an Object in the response Object
* @ {?string} Lastname This is a optional string parameter Lastnameof an Object in the response Object
* @ {boolean} IsAdultThis is a booleanparameter IsAdultThis of an Object in the response Object
*
* @returns {object} response
* @ {any} anything Anything can be guven as value LOL (1 | "abc", true | [])
* @ {?any} anything_optional !OPTIONAL Anything can be guven as value LOL (1 | "abc", true | [])
* @ {string} string This is a normal String as Parameter ("Any String")
* @ {boolean} boolean This is a Boolean as Parameter (true/false | t/f | "true"/"false")
* @ {number} number This is a Number as a Parameter (1 | -1 | 1.23432 | 2e+100)
* @ {float} float This is a Float as a Parameter, its basically a alias for float (1 | -1 | 1.23432 | 2e+100)
* @ {integer} integer This is a Integer as a Parameter (1 | -1 | 1000 | 2e+100)
* @ {object.http} object_http An object representing an HTTP Response. Accepts headers, body and statusCode keys
* @ {buffer} buffer Buffer Data representing a file
* @ {number} enumvalue the value of the given Enum
* @ {array} Array This is a Array as a Parameter
* @ {object} object Object
* @ {number} ID This is a number parameter ID of an Object in the response Object
* @ {string} Name This is a stringparameter Name of an Object in the response Object
* @ {?string} Lastname This is a optional string parameter Lastnameof an Object in the response Object
* @ {boolean} IsAdultThis This is a booleanparameter IsAdultThis of an Object in the response Object
*/
module.exports = async (
anything,
anything_optional = 'this is a default value & makes this parameter optional',
string,
boolean,
number,
float,
integer,
object_http,
buffer = {_base64: 'd2h5IGRpZCB5b3UgcGFyc2UgdGhpcz8/'},
enumerated,
array,
object
) => {
//NOW DO HERE SOMTHING WITH YOUR VALUES
let response = {
any: any,
anything_optional: anything_optional,
string: string,
boolean: boolean,
float: float,
integer: integer,
object_http: object_http,
buffer: buffer,
enumerated: enumerated,
array: arrayarray,
object: object,
};
//RETURN THE OBJECT MATCHING YOUR RETURN OBJECT
return response;
};