Hello community,
here is the log from the commit of package python-openapi-spec-validator for
openSUSE:Factory checked in at 2019-09-13 14:57:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-openapi-spec-validator (Old)
and /work/SRC/openSUSE:Factory/.python-openapi-spec-validator.new.7948
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-openapi-spec-validator"
Fri Sep 13 14:57:52 2019 rev:5 rq:730063 version:0.2.8
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-openapi-spec-validator/python-openapi-spec-validator.changes
2019-06-06 18:16:18.636703804 +0200
+++
/work/SRC/openSUSE:Factory/.python-openapi-spec-validator.new.7948/python-openapi-spec-validator.changes
2019-09-13 14:57:55.961276255 +0200
@@ -1,0 +2,6 @@
+Wed Sep 11 08:33:01 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.2.8:
+ * no upstream changelog
+
+-------------------------------------------------------------------
Old:
----
0.2.7.tar.gz
New:
----
0.2.8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-openapi-spec-validator.spec ++++++
--- /var/tmp/diff_new_pack.obawfR/_old 2019-09-13 14:57:56.401276274 +0200
+++ /var/tmp/diff_new_pack.obawfR/_new 2019-09-13 14:57:56.401276274 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-openapi-spec-validator
-Version: 0.2.7
+Version: 0.2.8
Release: 0
Summary: Python module for validating OpenAPI Specs against Swagger and
OAS3
License: Apache-2.0
@@ -28,6 +28,7 @@
Patch0: openapi-spec-validator-skip-urls.patch
BuildRequires: %{python_module PyYAML >= 5.1}
BuildRequires: %{python_module jsonschema}
+BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six}
@@ -36,6 +37,7 @@
BuildRequires: python-rpm-macros
Requires: python-PyYAML >= 5.1
Requires: python-jsonschema
+Requires: python-setuptools
Requires: python-six
Requires(post): update-alternatives
Requires(postun): update-alternatives
++++++ 0.2.7.tar.gz -> 0.2.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/.bumpversion.cfg
new/openapi-spec-validator-0.2.8/.bumpversion.cfg
--- old/openapi-spec-validator-0.2.7/.bumpversion.cfg 1970-01-01
01:00:00.000000000 +0100
+++ new/openapi-spec-validator-0.2.8/.bumpversion.cfg 2019-07-22
17:07:11.000000000 +0200
@@ -0,0 +1,14 @@
+[bumpversion]
+current_version = 0.2.8
+commit = True
+tag = True
+parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
+serialize =
+ {major}.{minor}.{patch}
+tag_name = {new_version}
+message = Version {new_version}
+
+[bumpversion:file:openapi_spec_validator/__init__.py]
+
+[bumpversion:file:Dockerfile]
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/.travis.yml
new/openapi-spec-validator-0.2.8/.travis.yml
--- old/openapi-spec-validator-0.2.7/.travis.yml 2019-05-20
11:36:21.000000000 +0200
+++ new/openapi-spec-validator-0.2.8/.travis.yml 2019-07-22
17:07:11.000000000 +0200
@@ -16,6 +16,7 @@
allow_failures:
- python: 3.2 # EOL
- python: 3.3 # EOL
+ - python: 3.4 # EOL
- python: nightly
before_install:
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then pip install 'coverage<4.0.0';
fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/Dockerfile
new/openapi-spec-validator-0.2.8/Dockerfile
--- old/openapi-spec-validator-0.2.7/Dockerfile 1970-01-01 01:00:00.000000000
+0100
+++ new/openapi-spec-validator-0.2.8/Dockerfile 2019-07-22 17:07:11.000000000
+0200
@@ -0,0 +1,7 @@
+FROM python:3.7-alpine
+
+ARG OPENAPI_SPEC_VALIDATOR_VERSION=0.2.8
+
+RUN pip install --no-cache-dir
openapi-spec-validator==${OPENAPI_SPEC_VALIDATOR_VERSION}
+
+ENTRYPOINT ["openapi-spec-validator"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/Makefile
new/openapi-spec-validator-0.2.8/Makefile
--- old/openapi-spec-validator-0.2.7/Makefile 1970-01-01 01:00:00.000000000
+0100
+++ new/openapi-spec-validator-0.2.8/Makefile 2019-07-22 17:07:11.000000000
+0200
@@ -0,0 +1,45 @@
+.EXPORT_ALL_VARIABLES:
+
+PROJECT_NAME=openapi-spec-validator
+PACKAGE_NAME=$(subst -,_,${PROJECT_NAME})
+VERSION=`git describe --abbrev=0`
+
+DOCKER_REGISTRY=p1c2u
+
+PYTHONDONTWRITEBYTECODE=1
+
+params:
+ @echo "Project name: ${PROJECT_NAME}"
+ @echo "Package name: ${PACKAGE_NAME}"
+ @echo "Version: ${VERSION}"
+
+dist-build:
+ @python setup.py bdist_wheel
+
+dist-cleanup:
+ @rm -rf build dist ${PACKAGE_NAME}.egg-info
+
+dist-upload:
+ @twine upload dist/*.whl
+
+test-python:
+ @python setup.py test
+
+test-cache-cleanup:
+ @rm -rf .pytest_cache
+
+reports-cleanup:
+ @rm -rf reports
+
+test-cleanup: test-cache-cleanup reports-cleanup
+
+cleanup: dist-cleanup test-cleanup
+
+docker-build:
+ @docker build --no-cache --build-arg
OPENAPI_SPEC_VALIDATOR_VERSION=${VERSION} -t ${PROJECT_NAME}:${VERSION} .
+
+docker-tag:
+ @docker tag ${PROJECT_NAME}:${VERSION}
${DOCKER_REGISTRY}/${PROJECT_NAME}:${VERSION}
+
+docker-push:
+ @docker push ${DOCKER_REGISTRY}/${PROJECT_NAME}:${VERSION}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/README.md
new/openapi-spec-validator-0.2.8/README.md
--- old/openapi-spec-validator-0.2.7/README.md 2019-05-20 11:36:21.000000000
+0200
+++ new/openapi-spec-validator-0.2.8/README.md 2019-07-22 17:07:11.000000000
+0200
@@ -25,6 +25,12 @@
$ openapi-spec-validator some.yaml
```
+pipes way:
+
+```bash
+$ cat some.yaml | openapi-spec-validator -
+```
+
or more pythonic way:
```bash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/openapi-spec-validator-0.2.7/openapi_spec_validator/__init__.py
new/openapi-spec-validator-0.2.8/openapi_spec_validator/__init__.py
--- old/openapi-spec-validator-0.2.7/openapi_spec_validator/__init__.py
2019-05-20 11:36:21.000000000 +0200
+++ new/openapi-spec-validator-0.2.8/openapi_spec_validator/__init__.py
2019-07-22 17:07:11.000000000 +0200
@@ -2,14 +2,14 @@
from openapi_spec_validator.shortcuts import (
validate_spec_factory, validate_spec_url_factory,
)
-from openapi_spec_validator.handlers import UrlHandler
+from openapi_spec_validator.handlers import UrlHandler, FileObjectHandler
from openapi_spec_validator.schemas import get_openapi_schema
from openapi_spec_validator.factories import JSONSpecValidatorFactory
from openapi_spec_validator.validators import SpecValidator
__author__ = 'Artur Maciag'
__email__ = '[email protected]'
-__version__ = '0.2.7'
+__version__ = '0.2.8'
__url__ = 'https://github.com/p1c2u/openapi-spec-validator'
__license__ = 'Apache License, Version 2.0'
@@ -19,8 +19,10 @@
'validate_v2_spec_url', 'validate_v3_spec_url', 'validate_spec_url',
]
+file_object_handler = FileObjectHandler()
+all_urls_handler = UrlHandler('http', 'https', 'file')
default_handlers = {
- '<all_urls>': UrlHandler('http', 'https', 'file'),
+ '<all_urls>': all_urls_handler,
'http': UrlHandler('http'),
'https': UrlHandler('https'),
'file': UrlHandler('file'),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/openapi-spec-validator-0.2.7/openapi_spec_validator/__main__.py
new/openapi-spec-validator-0.2.8/openapi_spec_validator/__main__.py
--- old/openapi-spec-validator-0.2.7/openapi_spec_validator/__main__.py
2019-05-20 11:36:21.000000000 +0200
+++ new/openapi-spec-validator-0.2.8/openapi_spec_validator/__main__.py
2019-07-22 17:07:11.000000000 +0200
@@ -7,8 +7,10 @@
import pathlib2 as pathlib
import sys
-
-from openapi_spec_validator import validate_spec_url, validate_v2_spec_url
+from openapi_spec_validator import (
+ openapi_v2_spec_validator, openapi_v3_spec_validator, all_urls_handler,
+ file_object_handler,
+)
from openapi_spec_validator.exceptions import ValidationError
logger = logging.getLogger(__name__)
@@ -18,6 +20,19 @@
)
+def read_from_stdin(filename):
+ return file_object_handler(sys.stdin), ''
+
+
+def read_from_filename(filename):
+ if not os.path.isfile(filename):
+ raise SystemError("No such file {0}".format(filename))
+
+ filename = os.path.abspath(filename)
+ uri = pathlib.Path(filename).as_uri()
+ return all_urls_handler(uri), uri
+
+
def main(args=None):
parser = argparse.ArgumentParser()
parser.add_argument('filename', help="Absolute or relative path to file")
@@ -29,21 +44,34 @@
default='3.0.0'
)
args = parser.parse_args(args)
- filename = args.filename
- filename = os.path.abspath(filename)
+
+ # choose source
+ reader = read_from_filename
+ if args.filename in ['-', '/-']:
+ reader = read_from_stdin
+
+ # read source
+ try:
+ spec, spec_url = reader(args.filename)
+ except Exception as exc:
+ print(exc)
+ sys.exit(1)
+
# choose the validator
- if args.schema == '2.0':
- validate_url = validate_v2_spec_url
- elif args.schema == '3.0.0':
- validate_url = validate_spec_url
+ validators = {
+ '2.0': openapi_v2_spec_validator,
+ '3.0.0': openapi_v3_spec_validator,
+ }
+ validator = validators[args.schema]
+
# validate
try:
- validate_url(pathlib.Path(filename).as_uri())
- except ValidationError as e:
- print(e)
+ validator.validate(spec, spec_url=spec_url)
+ except ValidationError as exc:
+ print(exc)
sys.exit(1)
- except Exception as e:
- print(e)
+ except Exception as exc:
+ print(exc)
sys.exit(2)
else:
print('OK')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/openapi-spec-validator-0.2.7/openapi_spec_validator/handlers.py
new/openapi-spec-validator-0.2.8/openapi_spec_validator/handlers.py
--- old/openapi-spec-validator-0.2.7/openapi_spec_validator/handlers.py
2019-05-20 11:36:21.000000000 +0200
+++ new/openapi-spec-validator-0.2.8/openapi_spec_validator/handlers.py
2019-07-22 17:07:11.000000000 +0200
@@ -8,19 +8,30 @@
from openapi_spec_validator.loaders import ExtendedSafeLoader
-class UrlHandler:
- """OpenAPI spec validator URL scheme handler."""
+class FileObjectHandler(object):
+ """OpenAPI spec validator file-like object handler."""
- def __init__(self, *allowed_schemes, **options):
- self.allowed_schemes = allowed_schemes
+ def __init__(self, **options):
self.options = options
@property
def loader(self):
return self.options.get('loader', ExtendedSafeLoader)
+ def __call__(self, f):
+ return load(f, self.loader)
+
+
+class UrlHandler(FileObjectHandler):
+ """OpenAPI spec validator URL scheme handler."""
+
+ def __init__(self, *allowed_schemes, **options):
+ super(UrlHandler, self).__init__(**options)
+ self.allowed_schemes = allowed_schemes
+
def __call__(self, url, timeout=1):
assert urlparse(url).scheme in self.allowed_schemes
- with contextlib.closing(urlopen(url, timeout=timeout)) as fh:
- return load(fh, self.loader)
+ f = urlopen(url, timeout=timeout)
+ with contextlib.closing(f) as fh:
+ return super(UrlHandler, self).__call__(fh)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/setup.py
new/openapi-spec-validator-0.2.8/setup.py
--- old/openapi-spec-validator-0.2.7/setup.py 2019-05-20 11:36:21.000000000
+0200
+++ new/openapi-spec-validator-0.2.8/setup.py 2019-07-22 17:07:11.000000000
+0200
@@ -28,8 +28,10 @@
self.test_args = [
'-sv',
'--flake8',
+ '--junitxml', 'reports/junit.xml',
'--cov', 'openapi_spec_validator',
'--cov-report', 'term-missing',
+ '--cov-report', 'xml:reports/coverage.xml',
]
self.test_suite = True
@@ -87,7 +89,6 @@
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/openapi-spec-validator-0.2.7/tests/integration/test_main.py
new/openapi-spec-validator-0.2.8/tests/integration/test_main.py
--- old/openapi-spec-validator-0.2.7/tests/integration/test_main.py
2019-05-20 11:36:21.000000000 +0200
+++ new/openapi-spec-validator-0.2.8/tests/integration/test_main.py
2019-07-22 17:07:11.000000000 +0200
@@ -1,4 +1,7 @@
+import mock
+
import pytest
+from six import StringIO
from openapi_spec_validator.__main__ import main
@@ -39,8 +42,32 @@
main(testargs)
[email protected](
+ 'openapi_spec_validator.__main__.openapi_v3_spec_validator.validate',
+ side_effect=Exception,
+)
+def test_unknown_error(m_validate):
+ """SystemExit on running with unknown error."""
+ testargs = ['--schema', '3.0.0',
+ './tests/integration/data/v2.0/petstore.yaml']
+ with pytest.raises(SystemExit):
+ main(testargs)
+
+
def test_nonexisting_file():
"""Calling with non-existing file should sys.exit."""
testargs = ['i_dont_exist.yaml']
with pytest.raises(SystemExit):
main(testargs)
+
+
+def test_schema_stdin():
+ """Test schema from STDIN"""
+ spes_path = './tests/integration/data/v3.0/petstore.yaml'
+ with open(spes_path, 'r') as spec_file:
+ spec_lines = spec_file.readlines()
+ spec_io = StringIO("".join(spec_lines))
+
+ testargs = ['-']
+ with mock.patch('openapi_spec_validator.__main__.sys.stdin', spec_io):
+ main(testargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/openapi-spec-validator-0.2.7/tox.ini
new/openapi-spec-validator-0.2.8/tox.ini
--- old/openapi-spec-validator-0.2.7/tox.ini 2019-05-20 11:36:21.000000000
+0200
+++ new/openapi-spec-validator-0.2.8/tox.ini 2019-07-22 17:07:11.000000000
+0200
@@ -1,5 +1,5 @@
[tox]
-envlist = {py27,py34,py35,py36}-{default,simplejson}
+envlist = {py27,py35,py36}-{default,simplejson}
[testenv]
deps =