Skip to content

Commit

Permalink
allow http and https scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszsip committed Nov 29, 2017
1 parent 88f4345 commit 3eb61c9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions validator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import sys
from jsonschema.exceptions import RefResolutionError
from colors import color
from os import path, getcwd
from openapi_spec_validator.handlers import UrlHandler

from colors import color
from jsonschema.exceptions import RefResolutionError
from openapi_spec_validator import openapi_v3_spec_validator
from openapi_spec_validator.handlers import UrlHandler
from six.moves.urllib.parse import urlparse


def validate(file_name):
def validate(url):
counter = 0

try:
handler = UrlHandler('file')
url = 'file://' + path.join(getcwd(), file_name)
handler = UrlHandler('http', 'https', 'file')

if not urlparse(url).scheme:
url = 'file://' + path.join(getcwd(), url)

spec = handler(url)

for i in openapi_v3_spec_validator.iter_errors(spec, spec_url=url):
Expand Down

0 comments on commit 3eb61c9

Please sign in to comment.