Skip to content

Commit

Permalink
Merge pull request #57 from ReputationVIP/add-read-the-doc
Browse files Browse the repository at this point in the history
Add read the doc
  • Loading branch information
tejerka committed Aug 31, 2018
2 parents b8e1770 + 9ba2961 commit de68bec
Show file tree
Hide file tree
Showing 5 changed files with 1,486 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/API.rst
@@ -0,0 +1,58 @@
.. _API:

===
API
===

Mockservr exposes an HTTP API which allow to get information about current endpoints, and to update them if needed.
This API is available through HTTP queries on `http://localhost:4580` (the API is exposed through the port 4580 of
the Mockservr's container).

-------------
API Endpoints
-------------

All endpoints are JSON endpoints (`Content-Type: application/json`) and must be prefixed with `/api`.

`/api` endpoint
===============

`GET` method
~~~~~~~~~~~~

The response is an object with a single attribute `httpEndpoints`, it contains the number of endpoints currently served
by Mockservr.

`/api/http-endpoints` endpoint
==============================

`GET` Method
~~~~~~~~~~~~

The response is a collection of all HTTP endpoints cuurrently served by Mockservr. The response includes the internal
ID of the endpoint and the source (mock file or API).

`POST` method
~~~~~~~~~~~~~

It expects a JSON body as defined in :ref:`http_mocking`, defining an endpoint with a Request and a Response.

The response contains the newly created endpoint with its ID and source. If any error occurred, the response is an
HTTP 400 response with a json object that contains all encountered errors.

`/api/http-endpoints/:id` endpoint
==================================

`GET` Method
~~~~~~~~~~~~

The response is an object defining the endpoint corresponding to the given `:id`.

`DELETE` method
~~~~~~~~~~~~~

Deletes the endpoint from Mockservr. The response is an HTTP 204 response. If any error occurred, the response is an
HTTP 400 response with a json object that contains all encountered errors.

.. note::
`DELETE` method does not delete the mock file, if the target endpoint is defined in a mock file.

0 comments on commit de68bec

Please sign in to comment.