instrumenta / openapi2jsonschema

Convert OpenAPI definitions into JSON schemas for all types in the API
Other
226 stars 87 forks source link

Incompatibility with python 3 and open local file instead of url #6

Closed jcketz closed 6 years ago

jcketz commented 6 years ago

Hi, thanks for your work, but I faced few problems: Your code is Incompatible with python and you can't load a local file : here are the modifications for python3 compatibility and local file choice

import urllib
from urllib.request import Request, urlopen
...
    info("Downloading schema")
    if (urllib.parse.urlparse(schema).scheme != ""):
        req = Request(schema,headers={'User-Agent': 'Mozilla/5.0'})
        response = urllib.request.urlopen(req)
    else:
        response  = open(schema, "r")
    info("Parsing schema")
...
consideRatio commented 6 years ago

Dang - same for me, thanks for providing code @jcketz !

@garethr kubeval made me very happy recently by finding previously silent failures in --strict mode. But when used with kubernetes 1.10.4 or 1.9+ really the strict mode was lacking so I hoped to use these tools to get a schema and perhaps make a PR, but then I ran into this instead!

garethr commented 6 years ago

This should be fixed in master now.