Skip to content

Commit 6133d94

Browse files
authored
Merge pull request #105 from p1c2u/feature/readme-md-to-rst
move to rst and setup.cfg
2 parents 4170be7 + 0c77f85 commit 6133d94

File tree

4 files changed

+188
-162
lines changed

4 files changed

+188
-162
lines changed

README.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

README.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
**********************
2+
OpenAPI Spec validator
3+
**********************
4+
5+
.. image:: https://img.shields.io/pypi/v/openapi-spec-validator.svg
6+
:target: https://pypi.python.org/pypi/openapi-spec-validator
7+
.. image:: https://travis-ci.org/p1c2u/openapi-spec-validator.svg?branch=master
8+
:target: https://travis-ci.org/p1c2u/openapi-spec-validator
9+
.. image:: https://img.shields.io/codecov/c/github/p1c2u/openapi-spec-validator/master.svg?style=flat
10+
:target: https://codecov.io/github/p1c2u/openapi-spec-validator?branch=master
11+
.. image:: https://img.shields.io/pypi/pyversions/openapi-spec-validator.svg
12+
:target: https://pypi.python.org/pypi/openapi-spec-validator
13+
.. image:: https://img.shields.io/pypi/format/openapi-spec-validator.svg
14+
:target: https://pypi.python.org/pypi/openapi-spec-validator
15+
.. image:: https://img.shields.io/pypi/status/openapi-spec-validator.svg
16+
:target: https://pypi.python.org/pypi/openapi-spec-validator
17+
18+
About
19+
#####
20+
21+
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs
22+
against the `OpenAPI 2.0 (aka
23+
Swagger) <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md>`__
24+
and `OpenAPI
25+
3.0.0 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md>`__
26+
specification. The validator aims to check for full compliance with the
27+
Specification.
28+
29+
Installation
30+
############
31+
32+
::
33+
34+
$ pip install openapi-spec-validator
35+
36+
Usage
37+
#####
38+
39+
Command Line Interface
40+
**********************
41+
42+
Straight forward way:
43+
44+
.. code:: bash
45+
46+
$ openapi-spec-validator some.yaml
47+
48+
pipes way:
49+
50+
.. code:: bash
51+
52+
$ cat some.yaml | openapi-spec-validator -
53+
54+
docker way:
55+
56+
.. code:: bash
57+
58+
$ docker run -v path/to/some.yaml:/some.yaml --rm p1c2u/openapi-spec-validator /some.yaml
59+
60+
or more pythonic way:
61+
62+
.. code:: bash
63+
64+
$ python -m openapi_spec_validator some.yaml
65+
66+
Examples
67+
********
68+
69+
Validate spec:
70+
71+
.. code:: python
72+
73+
74+
from openapi_spec_validator import validate_spec
75+
76+
validate_spec(spec_dict)
77+
78+
Add ``spec_url`` to validate spec with relative files:
79+
80+
.. code:: python
81+
82+
83+
from openapi_spec_validator import validate_spec
84+
85+
validate_spec(spec_dict, spec_url='file:///path/to/spec/openapi.yaml')
86+
87+
You can also validate spec from url:
88+
89+
.. code:: python
90+
91+
92+
from openapi_spec_validator import validate_spec_url
93+
94+
validate_spec_url('http://example.com/openapi.json')
95+
96+
If you want to iterate through validation errors:
97+
98+
.. code:: python
99+
100+
101+
from openapi_spec_validator import openapi_v3_spec_validator
102+
103+
errors_iterator = openapi_v3_spec_validator.iter_errors(spec)
104+
105+
Related projects
106+
################
107+
108+
* `openapi-core <https://github.com/p1c2u/openapi-core>`__
109+
Python library that adds client-side and server-side support for the OpenAPI.
110+
* `openapi-schema-validator <https://github.com/p1c2u/openapi-schema-validator>`__
111+
Python library that validates schema against the OpenAPI Schema Specification v3.0.
112+
113+
License
114+
#######
115+
116+
Copyright (c) 2017-2021, Artur Maciag, All rights reserved. Apache v2

setup.cfg

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[metadata]
2+
name = openapi-spec-validator
3+
description = OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0.0 spec validator
4+
long_description = file: README.rst
5+
long-description-content-type = text/x-rst; charset=UTF-8
6+
keywords = openapi, swagger, schema
7+
classifiers =
8+
Development Status :: 4 - Beta
9+
Intended Audience :: Developers
10+
Topic :: Software Development :: Libraries :: Python Modules
11+
Operating System :: OS Independent
12+
Programming Language :: Python :: 2.7
13+
Programming Language :: Python :: 3.5
14+
Programming Language :: Python :: 3.6
15+
Programming Language :: Python :: 3.7
16+
Programming Language :: Python :: 3.8
17+
Programming Language :: Python :: 3.9
18+
19+
[options]
20+
include_package_data = True
21+
packages = find:
22+
zip_safe = False
23+
test_suite = tests
24+
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
25+
setup_requires =
26+
setuptools
27+
install_requires =
28+
jsonschema
29+
PyYAML>=5.1
30+
six
31+
pathlib2; python_version<"3.0"
32+
tests_require =
33+
mock; python_version<"3.0"
34+
pytest
35+
pytest-flake8
36+
pytest-cov
37+
tox
38+
39+
[options.entry_points]
40+
console_scripts =
41+
openapi-spec-validator = openapi_spec_validator.__main__:main
42+
43+
[options.packages.find]
44+
exclude =
45+
tests
46+
47+
[options.extras_require]
48+
dev = pre-commit
49+
50+
[tool:pytest]
51+
addopts = -sv --flake8 --junitxml reports/junit.xml --cov openapi_spec_validator --cov-report term-missing --cov-report xml:reports/coverage.xml

setup.py

Lines changed: 21 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
"""OpenAPI spec validator setup module"""
23
import os
34
import re
45
import sys
5-
6-
from setuptools import find_packages, setup
7-
from setuptools.command.test import test as TestCommand
6+
try:
7+
from setuptools import setup
8+
except ImportError:
9+
from ez_setup import use_setuptools
10+
use_setuptools()
11+
from setuptools import setup
12+
finally:
13+
from setuptools.command.test import test as TestCommand
814

915

1016
def read_file(filename):
@@ -20,85 +26,30 @@ def get_metadata(init_file):
2026

2127

2228
class PyTest(TestCommand):
23-
2429
"""Command to run unit tests after in-place build."""
2530

2631
def finalize_options(self):
2732
TestCommand.finalize_options(self)
28-
self.test_args = [
29-
'-sv',
30-
'--flake8',
31-
'--junitxml', 'reports/junit.xml',
32-
'--cov', 'openapi_spec_validator',
33-
'--cov-report', 'term-missing',
34-
'--cov-report', 'xml:reports/coverage.xml',
35-
]
36-
self.test_suite = True
33+
self.pytest_args = []
3734

3835
def run_tests(self):
3936
# Importing here, `cause outside the eggs aren't loaded.
4037
import pytest
41-
errno = pytest.main(self.test_args)
38+
errno = pytest.main(self.pytest_args)
4239
sys.exit(errno)
4340

4441

4542
init_path = os.path.join('openapi_spec_validator', '__init__.py')
4643
init_py = read_file(init_path)
4744
metadata = get_metadata(init_py)
4845

49-
50-
setup(
51-
name='openapi-spec-validator',
52-
version=metadata['version'],
53-
author=metadata['author'],
54-
author_email=metadata['email'],
55-
url=metadata['url'],
56-
license=metadata['license'],
57-
description='OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0.0 spec validator',
58-
long_description=read_file('README.md'),
59-
long_description_content_type='text/markdown',
60-
packages=find_packages(include=('openapi_spec_validator*',)),
61-
package_data={
62-
'openapi_spec_validator': [
63-
'openapi_spec_validator/resources/schemas/v3.0.0/*',
64-
'openapi_spec_validator/resources/schemas/v2.0/*',
65-
],
66-
},
67-
include_package_data=True,
68-
entry_points={
69-
'console_scripts': [
70-
'openapi-spec-validator = openapi_spec_validator.__main__:main'
71-
]
72-
},
73-
install_requires=[
74-
"jsonschema",
75-
"PyYAML>=5.1",
76-
"six",
77-
'pathlib2;python_version=="2.7"',
78-
],
79-
extras_require={
80-
'dev': [
81-
'pre-commit'
82-
]
83-
},
84-
tests_require=[
85-
"mock",
86-
"pytest",
87-
"pytest-flake8",
88-
"pytest-cov",
89-
"tox",
90-
],
91-
cmdclass={'test': PyTest},
92-
classifiers=[
93-
"Development Status :: 4 - Beta",
94-
"Intended Audience :: Developers",
95-
"Topic :: Software Development :: Libraries :: Python Modules",
96-
"Operating System :: OS Independent",
97-
"Programming Language :: Python :: 2.7",
98-
"Programming Language :: Python :: 3.5",
99-
"Programming Language :: Python :: 3.6",
100-
"Programming Language :: Python :: 3.7",
101-
"Programming Language :: Python :: 3.8",
102-
"Programming Language :: Python :: 3.9",
103-
],
104-
)
46+
if __name__ == '__main__':
47+
setup(
48+
version=metadata['version'],
49+
author=metadata['author'],
50+
author_email=metadata['email'],
51+
url=metadata['url'],
52+
license=metadata['license'],
53+
cmdclass={'test': PyTest},
54+
setup_cfg=True,
55+
)

0 commit comments

Comments
 (0)