Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running Swagger-tester for Heroku-pets example #45

Open
ujjwal08 opened this issue Jan 16, 2017 · 3 comments
Open

Error when running Swagger-tester for Heroku-pets example #45

ujjwal08 opened this issue Jan 16, 2017 · 3 comments
Assignees
Labels

Comments

@ujjwal08
Copy link

I was trying to test heroku-pets example file(http://editor.swagger.io/#/) using swagger tester. I am getting an error-

**ERROR:connexion.api:Failed to add operation for PUT /pet/

ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for POST /pet/

ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for GET /pet/

ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for GET /pet/{petId}

ResolverError: <ResolverError: Cannot resolve operationId "None"!>**
Starting testrun against hero.json or None using examples: True

Below is the code for my test.py file to run my configuration file for heroku-pets, which is i have saved locally in json format(config. file name- hero.json)

from swagger_tester import swagger_test

authorize_error = {
'get': {
'/pet/': [200,400, 404],
'/pet/{petId}': [200,400,404],
},
'post': {
'/pet/': [200,400, 404]
},
'put': {
'/pet/': [200,400, 404]
}
}
swagger_test('hero.json', authorize_error=authorize_error)

Below is my console output when i run my test.py file:

ujjwal@ujjwal:~/Desktop/dataweave$ python test.py
ERROR:connexion.api:Failed to add operation for PUT /pet/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 237, in add_paths
self.add_operation(method, path, endpoint, path_parameters)
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 189, in add_operation
resolver=self.resolver)
File "/usr/local/lib/python2.7/dist-packages/connexion/operation.py", line 210, in init
resolution = resolver.resolve(self)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 39, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for POST /pet/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 237, in add_paths
self.add_operation(method, path, endpoint, path_parameters)
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 189, in add_operation
resolver=self.resolver)
File "/usr/local/lib/python2.7/dist-packages/connexion/operation.py", line 210, in init
resolution = resolver.resolve(self)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 39, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for GET /pet/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 237, in add_paths
self.add_operation(method, path, endpoint, path_parameters)
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 189, in add_operation
resolver=self.resolver)
File "/usr/local/lib/python2.7/dist-packages/connexion/operation.py", line 210, in init
resolution = resolver.resolve(self)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 39, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for GET /pet/{petId}
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 237, in add_paths
self.add_operation(method, path, endpoint, path_parameters)
File "/usr/local/lib/python2.7/dist-packages/connexion/api.py", line 189, in add_operation
resolver=self.resolver)
File "/usr/local/lib/python2.7/dist-packages/connexion/operation.py", line 210, in init
resolution = resolver.resolve(self)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 39, in resolve
return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
File "/usr/local/lib/python2.7/dist-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>
Starting testrun against hero.json or None using examples: True
INFO:swagger_tester.swagger_tester:TESTING PUT /pet/?
INFO:swagger_tester.swagger_tester:Using FlaskClient, got status code 404 for ********** PUT /pet/?
INFO:swagger_tester.swagger_tester:Got expected authorized error on /pet/? with status 404
INFO:swagger_tester.swagger_tester:TESTING POST /pet/?
INFO:swagger_tester.swagger_tester:Using FlaskClient, got status code 404 for ********** POST /pet/?
INFO:swagger_tester.swagger_tester:Got expected authorized error on /pet/? with status 404
INFO:swagger_tester.swagger_tester:TESTING GET /pet/?limit=11
INFO:swagger_tester.swagger_tester:Using FlaskClient, got status code 404 for ********** GET /pet/?limit=11
INFO:swagger_tester.swagger_tester:Got expected authorized error on /pet/?limit=11 with status 404
INFO:swagger_tester.swagger_tester:TESTING GET /pet/string?
INFO:swagger_tester.swagger_tester:Using FlaskClient, got status code 404 for ********** GET /pet/string?
INFO:swagger_tester.swagger_tester:Got expected authorized error on /pet/string? with status 404

I have installed connexion framework also. How to resolve above errors and What is the expected output for testing ? Actually, I am new to swagger and want to learn how testing is done with help of swagger tester so that i can use this in my organisation.

Below is the code for heroku-pets config file in json format(hero.json):

{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "PetStore on Heroku",
"description": "This example has a working backend hosted in Heroku\n\nYou can try all HTTP operation described in this Swagger spec.\n\nFind source code of this API here\n"
},
"host": "petstore-api.herokuapp.com",
"basePath": "/pet",
"schemes": [
"http",
"https"
],
"consumes": [
"application/json",
"text/xml"
],
"produces": [
"application/json",
"text/html"
],
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit",
"in": "query",
"description": "number of pets to return",
"type": "integer",
"default": 11,
"minimum": 11,
"maximum": 10000
}
],
"responses": {
"200": {
"description": "List all pets",
"schema": {
"title": "Pets",
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
},
"post": {
"parameters": [
{
"name": "pet",
"in": "body",
"description": "The pet JSON you want to post",
"schema": {
"$ref": "#/definitions/Pet"
},
"required": true
}
],
"responses": {
"200": {
"description": "Make a new pet"
}
}
},
"put": {
"parameters": [
{
"name": "pet",
"in": "body",
"description": "The pet JSON you want to post",
"schema": {
"$ref": "#/definitions/Pet"
},
"required": true
}
],
"responses": {
"200": {
"description": "Updates the pet"
}
}
}
},
"/{petId}": {
"get": {
"parameters": [
{
"name": "petId",
"in": "path",
"type": "string",
"description": "ID of the pet",
"required": true
}
],
"responses": {
"200": {
"description": "Sends the pet with pet Id"
}
}
}
}
},
"definitions": {
"Pet": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"birthday": {
"type": "integer",
"format": "int32"
}
}
}
}
}

@cyprieng cyprieng self-assigned this Feb 13, 2017
@cyprieng cyprieng added the bug label Feb 13, 2017
@Swalloow
Copy link

I have experienced similar errors. Please help.

ERROR:connexion.api:Failed to add operation for GET /auth/list
Traceback (most recent call last):
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/api.py", line 237, in add_paths
    self.add_operation(method, path, endpoint, path_parameters)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/api.py", line 189, in add_operation
    resolver=self.resolver)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/operation.py", line 210, in __init__
    resolution = resolver.resolve(self)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/resolver.py", line 39, in resolve
    return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
    raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>
ERROR:connexion.api:Failed to add operation for GET /auth/status
Traceback (most recent call last):
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/api.py", line 237, in add_paths
    self.add_operation(method, path, endpoint, path_parameters)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/api.py", line 189, in add_operation
    resolver=self.resolver)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/operation.py", line 210, in __init__
    resolution = resolver.resolve(self)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/resolver.py", line 39, in resolve
    return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
  File "/Users/.pyenv/versions/sentience/lib/python2.7/site-packages/connexion/resolver.py", line 67, in resolve_function_from_operation_id
    raise ResolverError(msg)
ResolverError: <ResolverError: Cannot resolve operationId "None"!>

@leonardofoderaro
Copy link

leonardofoderaro commented May 14, 2017

Hi all,
I'm trying the Connexion library with Swagger, too.
I had the same issue at first but I think it's not a bug, it's just a missing property in our swagger.yaml file.
Please take a look at this file, from the Connexion's petstore example:

https://github.com/hjacobs/connexion-example/blob/master/swagger.yaml

first you need to add the 'operationId' property to your swagger.yaml file:

paths:
  /pets:
    get:
      tags: [Pets]
      operationId: app.get_pets
      summary: Get all pets

then you need to implement the proper function (with the same signature as you defined in swagger.yaml) inside your app:

#!/usr/bin/env python3

import connexion

def get_pets():
  return []  # your code here
 
if __name__ == '__main__':
    app = connexion.App(__name__, 8080,
    specification_dir='./swagger/')
    app.add_api('swagger.yaml', arguments={'title': 'your API title'})
    app.run()

I hope it helps.

@flavianh
Copy link
Member

flavianh commented Jun 11, 2017

@Swalloow @ujjwal08 Does @leonardofoderaro's solution help? Could you turn this discussion into a short stackoverflow post?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants