Skip to content

Commit

Permalink
docs: add tabs (proof of concept)
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Nov 16, 2018
1 parent ecef680 commit 72cf204
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 45 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -48,6 +48,7 @@
extensions = [
'cli_options',
'pygments_markdown_lexer',
'sphinx_tabs.tabs',
]

# The suffix(es) of source filenames.
Expand Down
106 changes: 61 additions & 45 deletions docs/quickstart.rst
Expand Up @@ -20,48 +20,54 @@ Document Your API
First, let’s design the API we are about to build and test. That means you will need to create an API description file, which will document how your API should look like. Dredd supports two formats of API description documents:

- `API Blueprint <https://apiblueprint.org/>`__
- `Swagger <https://swagger.io/>`__

If you choose API Blueprint, create a file called ``api-description.apib`` in the root of your project and save it with following content:

.. code-block:: apiblueprint
FORMAT: 1A
# GET /
+ Response 200 (application/json; charset=utf-8)
{"message": "Hello World!"}
If you choose Swagger, create a file called ``api-description.yml``:

.. code-block:: yaml
swagger: "2.0"
info:
version: "1.0"
title: Example API
license:
name: MIT
host: www.example.com
basePath: /
schemes:
- http
paths:
/:
get:
produces:
- application/json; charset=utf-8
responses:
200:
description: ""
schema:
type: object
properties:
message:
type: string
required:
- message
- `OpenAPI 2 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md>`__

.. tabs::

.. group-tab:: API Blueprint

If you choose API Blueprint, create a file called ``api-description.apib`` in the root of your project and save it with following content:

.. code-block:: apiblueprint
FORMAT: 1A
# GET /
+ Response 200 (application/json; charset=utf-8)
{"message": "Hello World!"}
.. group-tab:: OpenAPI 2

If you choose OpenAPI 2, create a file called ``api-description.yml``:

.. code-block:: yaml
swagger: "2.0"
info:
version: "1.0"
title: Example API
license:
name: MIT
host: www.example.com
basePath: /
schemes:
- http
paths:
/:
get:
produces:
- application/json; charset=utf-8
responses:
200:
description: ""
schema:
type: object
properties:
message:
type: string
required:
- message
Implement Your API
------------------
Expand Down Expand Up @@ -96,10 +102,20 @@ At this moment, the implementation is ready to be tested. Let’s run the server
Finally, let Dredd validate whether your freshly implemented API complies with the description you have:

.. code-block:: shell
.. tabs::

.. group-tab:: API Blueprint

.. code-block:: shell
$ dredd api-description.apib http://127.0.0.1:3000
.. group-tab:: OpenAPI 2

.. code-block:: shell
$ dredd api-description.yml http://127.0.0.1:3000
$ dredd api-description.apib http://127.0.0.1:3000 # API Blueprint
$ dredd api-description.yml http://127.0.0.1:3000 # Swagger
Configure Dredd
---------------
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Expand Up @@ -7,6 +7,7 @@ sphinx==1.8.1
jinja2==2.10
-e git://github.com/jhermann/pygments-markdown-lexer.git@e651a9a3f664285b01451eb39232b1ad9af65956#egg=pygments-markdown-lexer
pygments-apiblueprint==0.1.0
sphinx-tabs==1.1.9

# dev dependencies
doc8==0.8.0
Expand Down

0 comments on commit 72cf204

Please sign in to comment.