arpitBhalla / api-to-readme

Script to insert REST API endpoints to README.md

Home Page:https://www.npmjs.com/package/api-to-readme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API To README

Script to insert REST API endpoints to README.md

npm npm NPM Snyk Vulnerabilities for npm package Libraries.io dependency status for latest release


🚀 Getting Started

Install

npm install api-to-readme

Usage

/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

# run the script
node scripts/generateAPI.js

Before

/README.md

# My Awesome Project

...

## API Reference

<!-- api-start -->
<!-- api-end -->

...

After

/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 -->

...

🏁 Contribution

# Clone this project
$ git clone https://github.com/arpitBhalla/api-to-readme

# Access
$ cd api-to-readme

# Install dependencies
$ npm install

# Start contribution

📝 License

This project is under license from MIT. For more details, see the LICENSE file.

Made with ❤️ by Arpit Bhalla

Author

Arpit Bhalla

 

Back to top

About

Script to insert REST API endpoints to README.md

https://www.npmjs.com/package/api-to-readme

License:MIT License


Languages

Language:TypeScript 100.0%