|
1 | | -This is a script for a workshop about documenting REST APIs. |
2 | | -This is a technical script that will be just a part of the workshop. It covers the setup of documentation portal but not the part where we learn about REST API |
3 | | - |
4 | | -## Prerequisites |
5 | | - |
6 | | -You need to have the following software/modules/applications installed on your computer to be able to complete all the steps of the workshop. |
7 | | - |
8 | | -- Install Node.js and NPM: https://nodejs.org/en/download/ (both in one package) and then install: |
9 | | - - [DocPad](http://docpad.org/) by calling in the terminal: `npm install -g npm` |
10 | | - - [Gulp](http://gulpjs.com/) by calling in the terminal: `npm install -g gulp-cli` |
11 | | -- Get GitHub account: https://github.com/ |
12 | | -- Install GitHub Desktop: https://desktop.github.com/ |
13 | | -- Install some nice text editor like [Atom](https://atom.io/) or [Sublime Text](https://www.sublimetext.com/) |
14 | | - |
15 | | -## Configuring documentation publishing pipeline |
16 | | - |
17 | | -First you need to fork some projects and configure them correctly to set up the documentation independent generation pipeline. |
18 | | - |
19 | | -1. Fork the following repos (it means open the links and click on Fork button in the top right corner of the page): |
20 | | - - API Doc portal template: https://github.com/hybris/docpad-skeleton-apidocs |
21 | | - - Sample REST API microservice that we will be documenting: https://github.com/derberg/minerva |
22 | | - - Sample registry that integrates the template and docu sources: https://github.com/derberg/apidoc-workshop-docu_registry |
23 | | - |
24 | | -2. Configuration |
25 | | - - Modify `chewieConfig.js` file in forked `docpad-skeleton-apidocs` repository. Change the `path` attribute: |
26 | | - ``` |
27 | | - path: process.env.REGISTRY_PATH || 'https://github.com/derberg/apidoc-workshop-docu_registry.git' |
28 | | - ``` |
29 | | - The git url must point to your forked `apidoc-workshop-docu_registry` repository. |
30 | | - |
31 | | - - Modify `minerva.json` file in forked `apidoc-workshop-docu_registry` repository. Change the `location` attribute: |
32 | | - ``` |
33 | | - "location": "https://github.com/derberg/minerva" |
34 | | - ``` |
35 | | - The git url must point to your forked `minerva` repository. |
36 | | - |
37 | | -## Start the API Doc portal locally |
38 | | - |
39 | | -If configuration is completed you have to: |
40 | | - |
41 | | -1. Clone your forked `docpad-skeleton-apidocs` repository, |
42 | | - |
43 | | -2. Navigate to its local clone in the terminal, |
44 | | - |
45 | | -3. Call the following command: `npm start` |
46 | | - |
47 | | -4. Once the start is completed, open in the browser the following link: http://localhost:9778/ |
48 | | - |
49 | | -## Publishing to GitHub Pages |
50 | | - |
51 | | -The easiest solution is to publish the API Doc portal on GitHub pages. Of course the generated API Doc portal files can be hosted on any other server as it is pure static content. |
52 | | - |
53 | | -1. Create new repository with the following name: `your_github_username.github.io`. It must be public and initialized (You do it in UI during creation). |
54 | | - |
55 | | -2. Modify `chewieConfig.js` file in forked `docpad-skeleton-apidocs` repository. |
56 | | - - Change the `srcLocation` attribute: |
57 | | - ``` |
58 | | - srcLocation: 'https://github.com/derberg/derberg.github.io.git', |
59 | | - ``` |
60 | | - The git url must point to your newly created `your_github_username.github.io` repository. |
61 | | - - Change the `docuUrl` attribute: |
62 | | - ``` |
63 | | - docuUrl: process.env.docuURL || 'http://derberg.github.io', |
64 | | - ``` |
65 | | - The page url must be the same as the name of your newly created `your_github_username.github.io` repository. |
66 | | - |
67 | | -3. Modify `docpad.coffee` file in forked `docpad-skeleton-apidocs` repository. Change the `url` attribute: |
68 | | - ``` |
69 | | - environments: |
70 | | - prod: |
71 | | - templateData: |
72 | | - site: |
73 | | - url: "http://derberg.github.io" |
74 | | - ``` |
75 | | - It should point to the following url: `http://your_github_username.github.io` |
76 | | - |
77 | | -4. Navigate to the local clone of `docpad-skeleton-apidocs` repository in the terminal |
78 | | - |
79 | | -5. Call the following command: `npm run production` |
80 | | - |
81 | | -6. Call the following command: `gulp pushResult` |
82 | | - |
83 | | -7. Once the push is completed, open in the browser the following link: http://your_github_username.github.io |
| 1 | +## REST API -> The easiest and coolest docu to write |
| 2 | + |
| 3 | +This is a script for a workshop about documenting REST APIs. The workshop covers two aspects: |
| 4 | +- Learning what REST API is, |
| 5 | +- Setting up a portal with REST API documentation. |
| 6 | + |
| 7 | +## Intro |
| 8 | + |
| 9 | +REST API in most cases is used in the cloud environment. It you are documenting REST API for cloud - you are lucky because: |
| 10 | +- You most likely have not only production but also stage environment set up permanently. This means you have a playground where you can check the API before you document it: |
| 11 | +``` |
| 12 | +Like for the sake of this workshop we have a real service running. |
| 13 | +Just navigate to this link in the browser: |
| 14 | + http://minerva.cfapps.io/events |
| 15 | +``` |
| 16 | +- In cloud all the peaces are independent and super easy to set up locally. |
| 17 | +``` |
| 18 | +Minerva service mentioned above is also easy to set up locally. Just follow below steps in the terminal: |
| 19 | +> git clone https://github.com/derberg/minerva.git |
| 20 | +> cd minerva |
| 21 | +> npm install |
| 22 | +> npm run develop |
| 23 | +``` |
| 24 | +- REST is easy to learn. |
| 25 | +``` |
| 26 | +Again navigate in the browser to the Minerva service: |
| 27 | +http://minerva.cfapps.io/events |
| 28 | +What just happened? You `GET` an info from the server! |
| 29 | +Same thing happens once you open in a browser any Web page. |
| 30 | +) Use for example a Chrome browser and go into the `Inspector` mode |
| 31 | +) Open https://www.google.com |
| 32 | +) See the first call in the `Network` tab. You `GET` pure HTML only |
| 33 | +``` |
| 34 | +- Whole Web speaks `REST`. Once you understand its rules, you'll understand how everything works on the Web. |
| 35 | +``` |
| 36 | +Why you can have an unofficial Twitter app on your mobile? |
| 37 | +Why you can have 3rd party apps in Facebook |
| 38 | +Why you can have a Google Map on your Web page |
| 39 | +``` |
| 40 | + |
| 41 | +## Details |
| 42 | + |
| 43 | +### Consuming and Theory |
| 44 | + |
| 45 | +- [API Clients](docu/apiclients.md) |
| 46 | +- [API Reference](docu/apireference.md) |
| 47 | + |
| 48 | +### Technical |
| 49 | + |
| 50 | +Let us document our own service and publish documentation for it to a public server. |
| 51 | + |
| 52 | +- [Prerequisites](docu/prerequisites.md) |
| 53 | +- [Set up and publishing](docu/using_docu_tool.md) |
| 54 | + |
| 55 | +### Extra tasks |
| 56 | + |
| 57 | +- Write a `Details` document, |
| 58 | +- API specification requires update in the schema for errors part |
| 59 | +- Now create a automated pipeline that will pick your changes and deploy to GitHub Pages. Use https://travis-ci.org/ |
0 commit comments