Script to insert REST API endpoints to README.md
npm install api-to-readme
/scripts/generateAPI.js
// ES5
const { makeReadme } = require('api-to-readme')
// Typescript
import { makeReadme, API } from 'api-to-readme'
const apis: API[]= [
{
name: "Search",
description: "Search for user",
endpoint: "/search/",
method: "GET",
queryString: [
{
type: "string",
name: "q",
description: "Search query",
required: true,
},
],
response: {
code: 200,
posts: [
{
name: "string",
},
{
name: "string",
},
],
},
},
]
makeReadme(apis, {
readmePath: path.join(__dirname, "README.md"),
startComment: "api-start",
endComment: "api-end",
})
# run the script
node scripts/generateAPI.js
/README.md
# My Awesome Project
...
## API Reference
<!-- api-start -->
<!-- api-end -->
...
/README.md
# My Awesome Project
...
## API Reference
<!-- api-start -->
### **Search**
Search for user
| Parameter | Type | Description |
| --------- | -------- | ------------------------- |
| `q` | `string` | **Required** Search query |
```http
GET /search/
```
- Response
```json
{
"code": 200,
"posts": [
{
"name": "string"
},
{
"name": "string"
}
]
}
```
<!-- api-end -->
...
# Clone this project
$ git clone https://github.com/arpitBhalla/api-to-readme
# Access
$ cd api-to-readme
# Install dependencies
$ npm install
# Start contribution
This project is under license from MIT. For more details, see the LICENSE file.
Made with ❤️ by Arpit Bhalla
Arpit Bhalla
- Website: arpitbhalla.me
- GitHub: arpitBhalla
- LinkedIn: arpitbhalla