-
Notifications
You must be signed in to change notification settings - Fork 36
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
Comments
I have experienced similar errors. Please help.
|
Hi all, https://github.com/hjacobs/connexion-example/blob/master/swagger.yaml first you need to add the 'operationId' property to your swagger.yaml file:
then you need to implement the proper function (with the same signature as you defined in swagger.yaml) inside your app:
I hope it helps. |
@Swalloow @ujjwal08 Does @leonardofoderaro's solution help? Could you turn this discussion into a short stackoverflow post? |
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"
}
}
}
}
}
The text was updated successfully, but these errors were encountered: