Open Tset-Noitamotua opened 7 years ago
Ok. there is no apis
key. But there is a paths
key. So I used that. Now I get
Located API. There are 32 primary resources. Crawling each...
Traceback (most recent call last):
File "sw2ps.py", line 113, in <module>
main()
File "sw2ps.py", line 73, in main
.format(resource['path'][1:]))
TypeError: string indices must be integers
Same result on Python2.7 and 3.6
UPDATE: What previously was the Resource Listing in Swagger 1.0 is now the Swagger Object in 2.0 and it does not hold the Paths Object (paths
) in a list like (apis
) - instead it's a dictionary. So I need to find out how iterate through a dict.
see #2
Swagger 1.0 example (for more details see 1.0 spec)
{
"swaggerVersion": "1.2",
"basePath": "http://localhost:8000/greetings",
"apis": [
{
"path": "/hello/{subject}",
"operations": [
{
"method": "GET",
"summary": "Greet our subject with hello!",
"type": "string",
"nickname": "helloSubject",
"parameters": [
{
"name": "subject",
"description": "The subject to be greeted.",
"required": true,
"type": "string",
"paramType": "path"
}
]
}
]
}
],
"models": {}
}
Swagger 2.0 example (for more details see 2.0 spec)
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
}
},
"host": "petstore.swagger.io",
"basePath": "/v1",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"type": "integer",
"format": "int32"
}
],
"responses": {
"200": {
"description": "An paged array of pets",
"headers": {
"x-next": {
"type": "string",
"description": "A link to the next page of responses"
}
},
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
I'm getting below error with Python 2.7.13 as well as with Python 3.6
Am I doing something wrong?