Skip to content

Commit

Permalink
Release 6.0.0
Browse files Browse the repository at this point in the history
Add changelog and callbacks documentation
Remove old documentation and images
  • Loading branch information
255kb committed Nov 29, 2023
1 parent 17eb605 commit 6d9286f
Show file tree
Hide file tree
Showing 409 changed files with 1,118 additions and 3,161 deletions.
2 changes: 1 addition & 1 deletion components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const Footer: FunctionComponent<{
</li>
<li className='mb-2'>
{/* Do not use <Link>, as routes with a dot inside get rewritten without trailing slash */}
<a href='/releases/5.1.0/' className='text-reset'>
<a href='/releases/6.0.0/' className='text-reset'>
Releases
</a>
</li>
Expand Down
6 changes: 3 additions & 3 deletions content/docs/latest/api-endpoints/crud-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ To create a CRUD route, click on the "CRUD route" entry in the add route menu:

Then, set its path, usually a [resource name](/articles/api-guide-rest-api-components/#resource-url-request):

![Set the CRUD route path{1264x176}](docs-img:set-crud-route-path.png)
![Set the CRUD route path{1495x176}](docs-img:set-crud-route-path.png)

> Your path can be more complex, and contains parameters or multiple sections. Remember that this will be the "prefix" of the different endpoints (see below).
## Data bucket link

After creating a CRUD endpoint, you need to link it to a data bucket:

![Link a data bucket to a CRUD route{1264x334}](docs-img:link-data-bucket-crud-route.png)
![Link a data bucket to a CRUD route{1495x334}](docs-img:link-data-bucket-crud-route.png)

> Head over to our [data buckets](docs:data-buckets/overview) documentation to learn how to create a new data bucket.
Expand Down Expand Up @@ -78,7 +78,7 @@ Mockoon will automatically translate a CRUD endpoint to multiple routes allowing

By default, CRUD endpoints will use the `id` property to identify objects in an array in all the routes manipulating a single resource (e.g. GET `/resource/:id`). However, you can change this property to anything you want, like `uuid`, `custom_id`, etc:

![Customize the CRUD id property{1264x334}](docs-img:customize-crud-id-property-key.png)
![Customize the CRUD id property{1495x334}](docs-img:customize-crud-id-property-key.png)

## Overriding a route

Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/api-endpoints/folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ order: 230

You can organize your routes into folders and sub-folders:

![routes organized in folders and sub-folders{799x522}](docs-img:routes-nested-folder.png)
![routes organized in folders and sub-folders{799x518}](docs-img:routes-nested-folder.png)

This new feature allows you to better organize your routes and make your APIs more readable and easier to navigate, with a clearer hierarchy.
You can drag and drop to move or reorganize your routes and folders.
Expand Down
11 changes: 7 additions & 4 deletions content/docs/latest/api-endpoints/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ In order to prefix all your mock API routes,

Open the **Environment Settings** by clicking on the tab at the top of the window:

![click on the settings tab{767x160}](docs-img:open-environment-settings.png)
![click on the settings tab{871x160}](docs-img:open-environment-settings.png)

Then, fill the **API prefix** input at the top of the **environment Settings**:

![fill the prefix input{995x298}](docs-img:environment-prefix.png)
![fill the prefix input{1108x298}](docs-img:environment-prefix.png)

The prefix will appear under your environment name in the environments list. All your environment's routes will now be prefixed and available at the following address `http://localhost:port/myprefix/myroute` instead of `http://localhost:port/myroute`.

Expand All @@ -45,15 +45,18 @@ Routes support certain patterns and a subset of regular expressions. Here are so
- `/ab+cd` will match `abcd`, `abbcd`, `abbbcd`, and so on.
- `/ab(cd)?e` will match `/abe` and `/abcde`.

![route pattern{956x74}](docs-img:route-patterns.png)
![route pattern{1168x74}](docs-img:route-patterns.png)

For a complete overview of the patterns available, please refer to Express' [route paths documentation](https://expressjs.com/en/guide/routing.html#route-paths).

> To use parentheses in your path as a normal character, you can escape them by either using a backslashe `\` or square brackets `[]`:
> `/part1[(]part2[)]` > `/part1\(part2\)`
### Route parameters

Route parameters can be defined in routes by using a colon `:`. The name of a parameter can only contains the following characters `A-Za-z0-9_`.

![route parameter{956x74}](docs-img:route-params.png)
![route parameter{1168x74}](docs-img:route-params.png)

For a complete overview on how to use and declare route parameters, please refer to Express' [route parameters documentation](https://expressjs.com/en/guide/routing.html#route-parameters).

Expand Down
10 changes: 5 additions & 5 deletions content/docs/latest/api-endpoints/templates-and-ai-assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To use a template in your routes, click on the "From template" entry in the rout

Then, select the template you want to use and either copy-paste its content manually or click on one of the two buttons to create a new **GET endpoint** or a **CRUD endpoint with a data bucket**.

![create get route from template{860x801}](docs-img:templates-create-get-route.png)
![create get route from template{860x759}](docs-img:templates-create-get-route.png)

The "GET route" button will create a new HTTP GET route and copy the template content as the body. The "CRUD + data" button will create a new CRUD endpoint with a linked data bucket and copy the template content as the data bucket content.

Expand All @@ -39,15 +39,15 @@ You can also use our AI assistant to generate realistic mock data for your vario

To generate a new template, click the "From template" button in the route creation menu (see above), and select the "Generate" tab:

![AI assistant generate tab{860x801}](docs-img:ai-assistant-generate-template-tab.png)
![AI assistant generate tab{860x759}](docs-img:ai-assistant-generate-template-tab.png)

Then, write a prompt (e.g. "list of users") and click the "Generate" button.

![AI assistant generate button click{860x801}](docs-img:ai-assistant-generate-button.png)
![AI assistant generate button click{860x759}](docs-img:ai-assistant-generate-button.png)

Finally, you can copy-paste the generated template manually or click on one of the two buttons to create a new **GET endpoint** or a **CRUD endpoint with a data bucket**.

![create get route from template{860x801}](docs-img:templates-generate-get-route.png)
![create get route from template{860x759}](docs-img:templates-generate-get-route.png)

### Writing prompts

Expand All @@ -58,7 +58,7 @@ Several options are available to fine-tune the generated templates:
- **array**: the generated template root level will be a JSON array (usually used with the **JSON** option).
- **templating**: the generated template will contain Handlebars [templating helpers](docs:templating/overview) (e.g. `{{faker 'person.firstName'}}`). Please note that disabling this option usually results in longer templates.

![prompt options buttons{860x801}](docs-img:ai-assistant-template-generate-options.png)
![prompt options buttons{860x759}](docs-img:ai-assistant-template-generate-options.png)

You will obtain best results with shorter prompts: "list of users", "JSON configuration for library X", etc.

Expand Down
36 changes: 36 additions & 0 deletions content/docs/latest/callbacks/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Overview
meta:
title: Callbacks overview
description: Learn how to create callbacks in Mockoon and how to trigger them from your route responses
order: 650
---

# Callbacks overview

---

## What are callbacks?

Callbacks are a way to **make one or more HTTP calls** after an entering request reaches your route. This is useful to **call other APIs or micro-services or to trigger a webhook**.

Callbacks are fully configurable and are created at the environment level, like the [data buckets](docs:data-buckets/overview).

## Create a callback

To create a new callback, open the **Callbacks** options by clicking on the tab at the top of the window:

![click on the callbacks tab at the top{955x160}](docs-img:open-callbacks-view.png)

Add a new callback by clicking on the "plus" button:

![Add a new callback by clicking on the plus button{1495x578}](docs-img:add-callback.png)

## Configure a callback

The callback configuration interface is very similar to the route response interface. You can configure the callback's **name**, **description**, **method**, **URL**, **body**, and **headers**:

- **URL**: the URL to call. Supports [templating helpers](docs:templating/overview).
- **Method**: the HTTP method to use for the call. Only some methods support a body (`POST`, `PUT`, and `PATCH`).
- **Body**: the body to send with the call. You can serve an inline body, a file, or the content of a [data bucket](docs:data-buckets/overview). They support templating too. Please refer to the [response body](docs:response-configuration/response-body) documentation for more details.
- **Headers**: the headers to send with the call. They support our [templating helpers](docs:templating/overview).
25 changes: 25 additions & 0 deletions content/docs/latest/callbacks/using-callbacks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Using callbacks
meta:
title: Using callbacks
description: Learn how to use Mockoon's callbacks, link them to your route responses and delay their execution
order: 651
---

# Using callbacks

---

After [creating callbacks](docs:callbacks/overview), you can link them in your route responses and delay their execution.

## Link a callback to a route response

To link a callback to a route response, choose "Callbacks" in the route response menu:

![click on the callbacks tab in the route response menu{1228x153}](docs-img:open-route-response-callbacks.png)

Then, click on the "plus" button to add a new callback, and select the callback you want to link:

![click on the plus button to add a new callback{1208x234}](docs-img:link-callback-response.png)

> 💡 You can **delay a callback execution** by adding a delay in milliseconds in the "Callback latency" field.
4 changes: 2 additions & 2 deletions content/docs/latest/data-buckets/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ The data buckets are defined at the **environment level** and are **generated wh

To create a new data bucket, open the **Data** options by clicking on the tab at the top of the window:

![Open data bucket view{742x160}](docs-img:open-data-view.png)
![Open data bucket view{745x160}](docs-img:open-data-view.png)

Add a new data bucket by clicking on the "plus" button:

![Add a data bucket{1264x578}](docs-img:add-data-bucket.png)
![Add a data bucket{1495x578}](docs-img:add-data-bucket.png)

You can change the data bucket title and content on the right part of the screen.
Mockoon will automatically attribute a new **unique ID** to your data bucket. You can use this ID to reference the data using the [`data` helpers](docs:data-buckets/using-data-buckets#using-data-helpers). To retrieve a bucket's unique ID, look in the footer under the data bucket content or right-click on a bucket name in the list and click on "Copy ID to clipboard".
Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/data-buckets/using-data-buckets.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ A data bucket can also be directly linked to a route response. Linking a data bu

To link a data bucket to a route response, choose "Data" in the body selector and select your data bucket.

![Using data bucket in a route response{1002x464}](docs-img:link-data-bucket-response.png)
![Using data bucket in a route response{1233x464}](docs-img:link-data-bucket-response.png)
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ You can automatically create mock routes from HTTP transactions (request/respons

Mockoon offers the possibility to automatically create mocks for entering requests. Click on the "plus" icon on a record to create a route containing the same information (headers, body, etc.):

![create a route from a log{1214x632}](docs-img:logs-auto-mocking.png)
![create a route from a log{1445x568}](docs-img:logs-auto-mocking.png)

## Record your API calls

Mockoon can also automatically create mock API endpoints every time a request is logged. To activate this feature, click on the "Record" button at the top of the logs view:

![click on the record button{1214x632}](docs-img:logs-start-recording.png)
![click on the record button{1445x568}](docs-img:logs-start-recording.png)

You can record in multiple environments at the same time. A red blinking recording icon will appear next to the environment name to indicate that the recording is active:

![recording icon{964x432}](docs-img:logs-recording-in-progress.png)
![recording icon{1195x368}](docs-img:logs-recording-in-progress.png)

The recording will only create a route once, based on the path and HTTP method.

Expand Down
12 changes: 6 additions & 6 deletions content/docs/latest/logging-and-recording/requests-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ order: 700

For easier debugging, Mockoon records all entering requests and all the corresponding outgoing responses for each of your mock API. To access an environment's log, click on the "Logs" tab at the top of the window:

![click the logs tab{801x160}](docs-img:open-logs.png)
![click the logs tab{913x160}](docs-img:open-logs.png)

## Logs content

The list shows all intercepted requests and how Mockoon answered to them.
Please note that all requests are intercepted, even the `/favicon` request made by the browser.
Each record contains the entering request and the outgoing response information. This includes the complete list of headers, route params, query params, and body in raw format.

![view the request{1214x632}](docs-img:logs-request.png)
![view the request{1445x568}](docs-img:logs-request.png)

![view the response{1214x632}](docs-img:logs-response.png)
![view the response{1445x568}](docs-img:logs-response.png)

The interface is showing truncated bodies for both the request and the response (the truncation length can be adjusted in the settings). You can still view them in full in a separated editor by clicking on **View full body in editor**:

![click on view full body in editor link{1214x632}](docs-img:logs-view-body.png)
![click on view full body in editor link{1445x568}](docs-img:logs-view-body.png)

![body content is showed in a modal{860x696}](docs-img:logs-view-body-modal.png)
![body content is showed in a modal{860x663}](docs-img:logs-view-body-modal.png)

## Logs metadata

You can also easily see if a request has been caught by Mockoon (record shows a green tick) or has been passed to another URL if the [proxy mode](docs:server-configuration/proxy-mode) is activated (record shows a shield icon):

![view logs metadata{1214x632}](docs-img:logs-metadata.png)
![view logs metadata{1445x568}](docs-img:logs-metadata.png)

## File logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ Since [v1.16.0](https://github.com/mockoon/mockoon/releases/tag/v1.16.0), Mockoo

You can locate the folder in which the API data are stored by right-clicking on each environment and selecting **"Show data file in explorer/finder"**:

![click on show in folder in the context menu{455x312}](docs-img:environment-show-in-folder.png)
![click on show in folder in the context menu{490x309}](docs-img:environment-show-in-folder.png)

## Moving the files

You can move the data files to another folder by right-clicking on an environment and selecting **"Move data file to folder"**:

![click on Move data file to folder in folder in the context menu{455x344}](docs-img:environment-move-to-folder.png)
![click on Move data file to folder in folder in the context menu{490x340}](docs-img:environment-move-to-folder.png)

> Please note that the environment file will be copied to the new folder, and the original file will **not** be deleted. If you want to delete the original file, you will have to do it manually.
## Enabling data file watching

Mockoon can monitor data files' external changes and automatically reload the interface with the new information. This is particularly useful when you are editing the data files with an external editor or pulling changes from a git repository. You can activate this option in the settings:

![enable file monitoring in the settings{860x812}](docs-img:enable-file-watching.png)
![enable file monitoring in the settings{860x770}](docs-img:enable-file-watching.png)

## Old system (pre v1.16.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ order: 920

To copy a specific environment or route's JSON data to the clipboard, right-click on the environment or route and select **Copy to clipboard (JSON)**:

![Right click on an environment and click on Copy to clipboard (JSON){655x331}](docs-img:export-clipboard-env.png)
![Right click on an environment and click on Copy to clipboard (JSON){690x328}](docs-img:export-clipboard-env.png)

The resulting JSON can be saved in a file and directly opened in the desktop app or used with the CLI.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Each file can be easily shared with other Mockoon's users, "as-is". After [locat
You can save your environment data files in a Git-tracked folder to make sharing easier. By default, an environment file JSON content is saved pretty-printed to allow comparing changes between two commits.
You can disable pretty printing in the settings:

![disable pretty printing{860x812}](docs-img:storage-pretty-printing.png)
![disable pretty printing{860x770}](docs-img:storage-pretty-printing.png)

### Use a mock API with the CLI

Expand Down
8 changes: 4 additions & 4 deletions content/docs/latest/response-configuration/file-serving.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Besides using the body editor, Mockoon allows you to serve different files for e

To serve a file, you must provide a path in the file input field:

![fill the file input field{987x354}](docs-img:file-path.png)
![fill the file input field{1218x354}](docs-img:file-path.png)

> When a file path is provided, the body editor content will be ignored.
## Absolute or relative paths

You can either provide an absolute path like `/home/username/file.json` or a relative path. Starting with [v1.16.0](https://github.com/mockoon/mockoon/releases/tag/v1.16.0), relative paths are resolved from the environment's file location. You can check the environment's file location by right-clicking on an environment en select "Show in folder" in the contextual menu:

![show in folder menu entry{455x312}](docs-img:environment-show-in-folder.png)
![show in folder menu entry{490x309}](docs-img:environment-show-in-folder.png)

> Prior to v1.16.0, relative file paths were resolved from the application executable. This is also supported by the CLI since its version [1.2.0](https://github.com/mockoon/cli/releases/tag/v1.2.0).
Expand All @@ -42,7 +42,7 @@ Templating can be disabled both for the body editor and the file content. Please
>
> Parsing the templating helpers inside big files can be a very intensive task (CPU and memory intensive). All the files in different formats than the one mentioned above will be streamed to improve performances.
> If you need to send big files in one of the above formats but don't need to parse the templating, you can disable it in the route response settings. It will stream the file instead of parsing it and improve the performance.
> ![disable templating in route response{1066x181}](docs-img:route-response-disable-templating.png)
> ![disable templating in route response{1297x181}](docs-img:route-response-disable-templating.png)
### File input templating

Expand All @@ -52,7 +52,7 @@ Templating is also supported directly in the **file input field**. It allows to

By default, Mockoon will return an error in the body when a file is not found. It will still keep the status code you set up on your route response. You can instead choose to automatically return a 404 by activating an option in the route response settings:

![tick the 404 fallback checkbox{1066x231}](docs-img:enable-404-fallback.png)
![tick the 404 fallback checkbox{1297x231}](docs-img:enable-404-fallback.png)

This option will also fall back to use the content present in the body editor.

Expand Down
Loading

0 comments on commit 6d9286f

Please sign in to comment.