Seamlessly Integrate Gravitee API Documentation with GitHub

With Gravitee.io, it is possible to retrieve multiple API documents from Bitbucket or Git (Git/GitHub/GitLab) and publish them to the portal. Once configured, every change made on the documentation in version control can be automatically pushed to the Gravitee Portal. With the help of the Gravitee descriptor file, it is possible to publish the pages on the Portal in a structured way: you can set one of the pages as the homepage and work with folders to maintain clean Documentation pages for your API’s.

Tim Rombouts
12 Jun 2024

How to

On the documentation page, go to ‘Import multiple files’

This will give you the option to import files from various sources like bitbucket, git, gitlab, github or any publicly accessible url. You can choose here if you want to immediately publish the files to the portal or only import them to the Manager and publish them manually later.

Scheduled fetch

To refresh the documentation from the source you can either use the ‘Fetch All’ button on the ‘Documentation’ tab or make use of the ‘Auto fetch’ feature while configuring the external source. If you use the ‘Auto fetch’ feature you have to specify the frequency of updates in crontab format.

Gravitee descriptor file

To import multiple pages there are 2 options:

  • import all files in a specific directory
  • use a gravitee descriptor file to import specific files in the directory and expose them in a structured way

For this blog we are going to explore the second option and use a gravitee descriptor file. This file needs to be named .gravitee.json and you must enter this file or its directory when configuring the import.

In this file you will list the files you want to publish on the portal and how you want them to be structured.

Example:

These are the files present on github:

After configuring this directory and executing a fetch of the files, this will result in the following behavior on the portal:

  • The parsed index.md markdown file on the ‘General information’ page of our API

  • On the ‘Documentation’ tab of our API we have:

    • a folder called ‘Code samples’ with 2 pages: the ‘Asciidoc page’ and the ‘Markdown page’
    • The ‘Swagger’ page loaded from openapi.yaml
Contact