Skip to content

Commit

Permalink
Merge pull request #4 from kejwmen/feature/allow-http
Browse files Browse the repository at this point in the history
Load external specs through http and https
  • Loading branch information
lcobucci authored Dec 5, 2017
2 parents 88f4345 + 3eb61c9 commit 8b829c7
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 8b829c7

Please sign in to comment.