mulesoft-labs / api-console-cli

A CLI tools for the API console.
Other
14 stars 15 forks source link

"GitHub requests limit exceeded" problem during api-console build #25

Closed growdai1y closed 6 years ago

growdai1y commented 6 years ago

I have a very simple raml file as below. And I'm trying to use "api-console" with the explanations in this github repo. However, the problem occurred which I really don't know how to resolve.

#%RAML 1.0
---
title: Jukebox API
baseUri: http://localhost
version: v1

/users:
    description: Collection of users in myspace service
    get:
        description: Get a list of all users
        queryParameters:
            limit:
                description: "the size of a list of users"
                example: 1
                required: false
                type: number
        responses:
            200:
                body:
                    application/json:
                        example: |
                            [
                                {"id": 1, "name": "younghyun"},
                                {"id": 2, "name": "sungmin"},
                                {"id": 3, "name": "youngin"}
                            ]
    post:
        body:
            application/json:
                example: |
                    {"name": "hynni"}
    /{userId}:
        get:
            responses:
                200:
                    body:
                        application/json:
                            example: |
                                {"id": 1, "name": "younghyun"}
                404:
                    body:
                        application/json:
                            example: |
                                {"message": "User not found"}

The error messages are as below.

PS C:\...> api-console build .\api\api.raml -o "./api-docs"
  Building the API console. This may take a moment.

Warning: You are trying to use local RAML file as an input but the --use-json optionis not set.
Users won't be able to access the RAML file. The CLI will use --use-json to generate a JSON file for build.

error:
error: GitHub requests limit exceeded
error: Error: GitHub requests limit exceeded
    at GithubResolver._handleResponseHeaders (C:\Users\yhyun\AppData\Roaming\npm\node_modules\api-console-cli\node_modules\api-console-github-resolver\lib\github-resolver.js:142:15)
    at _transport.get.then (C:\Users\yhyun\AppData\Roaming\npm\node_modules\api-console-cli\node_modules\api-console-github-resolver\lib\github-resolver.js:128:12)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
error:

Can anyone give me some clues to fix this problem?

Thanks in advance.

jarrodek commented 6 years ago

This issue resolves itself after up to an hour. GitHub API has hourly requests limit. The CLI tool uses this API to determine latest version of the console's sources. If you run the build command too many times in short time period this will happen.

Possible solutions

Wait

Wait a bit until quota reset

Use your own console's sources

Cli tool accepts -s argument that should point to a location of the API console sources. Download zip file from GitHub and point to this file. This will skip whole GitHub resolving stuff. Remember to use --source-is-zip (-z) for ZIP files.

api-console build -s ../api-console.zip api.raml

GITHUB_TOKEN variable

You can also set the GITHUB_TOKEN environment variable. You can generate GitHub personal token in your settings. This will increase rate limit to about 1000.

GITHUB_TOKEN="something" api-console build api.raml