Newton's Poleless Magnet

    api-to-readme
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    API To README

    Script to insert REST API endpoints to README.md

    MIT Issues Installs Start


    🚀 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

    Install

    npm i api-to-readme

    DownloadsWeekly Downloads

    7

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    8.99 kB

    Total Files

    7

    Last publish

    Collaborators

    • arpitbhalla