asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://pypi.org/project/RESTinstance
GNU Lesser General Public License v3.0
206 stars 84 forks source link

issue with parentheses ( ) in swagger endpoint #34

Closed leon-vg closed 5 years ago

leon-vg commented 6 years ago

With odata-based services, it is common to have endpoints with the following character:

/entity('A123')

I have made swagger documentation for this endpoint, but RESTinstance gives an incorrect error that this path is not found:

test                                                                | FAIL |
u'request':
    - 'path':
        - "No paths found for /entity('A123')"

I am under the impression that this has to do with the fact that the endpoint contains parentheses.

Here follows an example to reproduce this problem:

Swagger documentation: api-docs.json

{
    "info": {
        "title": "Test API",
        "version": "1"
    },
    "basePath": "/api/v1",
    "swagger": "2.0",
    "paths": {
        "/entity('{name}')": {
            "get": {
                "summary": "get odata endpoint",
                "parameters": [
                    {
                        "in": "path",
                        "name": "name",
                        "type": "string",
                        "required": true,
                        "description": "Name"
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "success"
                    }
                }
            }
        }
    },
    "definitions": {},
    "responses": {},
    "parameters": {},
    "securityDefinitions": {}
}

Robot Framework test

*** Settings ***
Library  REST  url=https://host/  spec=./api-docs.json

*** Test Cases ***
test
    REST.Get  /api/v1/entity('A123')
leon-vg commented 6 years ago

I think I tracked down the issue. It is in the 'flex' library: https://github.com/pipermerriam/flex/issues/204