Contribute to the Discourse API Docs ๐Ÿ“œ

Do you want to contribute to the official API documentation at https://docs.discourse.org/?
This guide will explain step by step how to do it. :slight_smile:

Prerequisites

You must have a Discourse development installation.

If you donโ€™t have one, follow the guide that suits your environment: Docs - Discourse Meta

Clone Discourse API docs repo

Weโ€™ll assume your Discourse development install is inside your home directory ~/.

From your home directory, clone https://github.com/discourse/discourse_api_docs :

git clone https://github.com/discourse/discourse_api_docs

You should now have discourse and discourse_api_docs folders side by side:

~/discourse/
~/discourse_api_docs/

Edit the API documentation files

You must edit the documentation directly from ~/discourse/spec/requests/api/.[1]

After editing the documentation files, run the following command from ~/discourse/:

bin/rake rswag:specs:swaggerize && cp openapi/openapi.yaml ~/discourse_api_docs/openapi.yml

The documentation will be generated using rswag and copied into ~/discourse_api_docs.

View your changes locally

To view your updated documentation, run these commands from ~/discourse_api_docs/

npm install
node server.js

Browse to http://localhost:3001 to see the pretty docs.
If everything looks good, create a pull request from the discourse/discourse repository (not the Discourse API Docs repository ).


  1. See the folder on Github: https://github.com/discourse/discourse/tree/main/spec/requests/api โ†ฉ๏ธŽ

15 Likes