linkSpec Config Section
Controls basics about where the endpoint lives (e.g. server, port).
These settings apply to all specs in an entire suite file.
1linkmeta:
2link name: Make sure Google loads
3link locate_files_relative: true
4linkconfiguration:
5link host: api.mycompany.com
6link scheme: http
7link port: 1337
8link base_path: /api/v3
9linkspecs:
10link - name: Fetch users
11link request:
12link method: get
13link path: /users
14link response:
15link status_code: 200
16link
linkscheme
- Type: string required
- Example:
https
- Values:
http
, https
What protocol (scheme) to use. Generally, http or https
linkhost
- Type: string required
- Example:
localhost
What server to use.
linkport
- Type: number optional
- Example:
8080
A custom port to use. Note that it must be a number.
linkbase_path
- Type: string optional
- Example:
/api
An optional base path to prepend to each URL.
linkcustom_configuration
- Type: JS Inline Function | JS Inline Async Function | JS Module optional
- Example: (see below)
Dynamically set any of the configuration using either an inline or external JS function.
linkJS Inline Function
See also:
1linkconfiguration:
2link scheme: https
3link port: 443
4link base_path: /api
5link custom_configuration:
6link run_type: inline
7link inline:
8link function: !!js/function >
9link function() {
10link if (process.env.NODE_ENV === 'dev') {
11link this.scheme = 'http';
12link this.port = 1337;
13link this.host = 'localhost;
14link return;
15link }
16link this.host = `${process.env.NODE_ENV || 'www'}.yourcompany.com`;
17link }
18link
19link
20link
linkJS Inline Async function
See also:
1linkconfiguration:
2link host: yourcompany.com
3link scheme: https
4link port: 443
5link base_path: /api
6link custom_configuration:
7link run_type: inline
8link inline:
9link function: !js/asyncFunction >
10link async function() {
11link this.scheme = 'http';
12link this.port = 3027;
13link }
14link
-linkJS Module
See also:
1linkconfiguration:
2link host: yourcompany.com
3link scheme: https
4link port: 443
5link base_path: /api
6link custom_configuration:
7link run_type: module
8link module:
9link module_path: config/test.js
10link function_name: configureForEnv