Nebo15 / annon.api

Configurable API gateway that acts as a reverse proxy with a plugin system.
http://docs.annon.apiary.io/
MIT License
331 stars 25 forks source link

Plugins: 422 validation_failed error #273

Closed cpursley closed 6 years ago

cpursley commented 6 years ago

First of all, great project! Thank you for creating it.

I'm running the docker compose configuration and am unable to create plugins from either the Annon Dashboard or HTTP. Here's an example of a failing request/response:

Request:

PUT /apis/99718b6a-09a5-4acf-9156-014e1291bc68/plugins/proxy HTTP/1.1
Host: 192.168.99.100:4001
Content-Type: application/json

{
  "plugin": {
    "name": "proxy",
    "is_enabled": true,
    "settings": {
      "upstream": {
        "scheme": "http",
        "host": "localhost",
        "port": 5000,
        "path": "/"
      },
      "preserve_host": false,
      "strip_api_path": false
    }
  }
}

Response:

{
    "meta": {
        "url": "http://192.168.99.100:4001/apis/99718b6a-09a5-4acf-9156-014e1291bc68/plugins/proxy",
        "type": "object",
        "request_id": "qg9kdeo86js3m4t0cp2j98mfk031j8rn",
        "code": 422
    },
    "error": {
        "type": "validation_failed",
        "message": "Validation failed. You can find validators description at our API Manifest: http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors.",
        "invalid": [
            {
                "rules": [
                    {
                        "rule": "required",
                        "params": [],
                        "description": "required property host was not present"
                    }
                ],
                "entry_type": "json_data_property",
                "entry": "$.settings.host"
            },
            {
                "rules": [
                    {
                        "rule": "schema",
                        "params": [
                            {
                                "upstream": {
                                    "scheme": "http",
                                    "port": 5000,
                                    "path": "/",
                                    "host": "localhost"
                                }
                            }
                        ],
                        "description": "schema does not allow additional properties"
                    }
                ],
                "entry_type": "json_data_property",
                "entry": "$.settings.upstream"
            }
        ]
    }
}

And here's a screenshot from the Dashboard:

dashboard

Perhaps there is an issue with my host format? But according to the API documentation, I believe I am submitting the request correctly.

AndrewDryga commented 6 years ago

Hey @cpursley, I believe you faced this issue because our documentation is a little bit ahead of time. There is no upstream object in plugin config. Try the following request:

PUT /apis/99718b6a-09a5-4acf-9156-014e1291bc68/plugins/proxy HTTP/1.1
Host: 192.168.99.100:4001
Content-Type: application/json

{
  "plugin": {
    "name": "proxy",
    "is_enabled": true,
    "settings": {
      "scheme": "http",
      "host": "localhost",
      "port": 5000,
      "path": "/"
      "preserve_host": false,
      "strip_api_path": false
    }
  }
}

I think we can keep this issue open until API is not changed.

AndrewDryga commented 6 years ago

Container v0.14.0 and master branch now is up to date with API doc 👍 .

AndrewDryga commented 6 years ago

@cpursley please tell if it still doesn't work for you :)