mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-06 04:19:26 +00:00
This PR updates the examples for Connexion 3.0 and merges them for OpenAPI and Swagger. 2 examples required some changes to make them work: - The reverse proxy example required some fixes to the SwaggerUIMiddleware to leverage the `root_path` correctly. This is included in the PR. - The enforced defaults example requires the json validator to adapt the body and pass it on. We currently pass on the original body after validation, and I'm not sure if we should change this. I'll submit a separate PR to discuss this.
127 lines
3.4 KiB
Python
Executable File
127 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import inspect
|
|
import os
|
|
import sys
|
|
|
|
from setuptools import find_packages, setup
|
|
from setuptools.command.test import test as TestCommand
|
|
|
|
__location__ = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))
|
|
|
|
|
|
def read_version(package):
|
|
with open(os.path.join(package, '__init__.py')) as fd:
|
|
for line in fd:
|
|
if line.startswith('__version__ = '):
|
|
return line.split()[-1].strip().strip("'")
|
|
|
|
|
|
version = read_version('connexion')
|
|
|
|
install_requires = [
|
|
'clickclick>=1.2,<21',
|
|
'jsonschema>=4.0.1,<5',
|
|
'PyYAML>=5.1,<7',
|
|
'requests>=2.27,<3',
|
|
'inflection>=0.3.1,<0.6',
|
|
'werkzeug>=2.2.1,<3',
|
|
'starlette>=0.19,<1',
|
|
'httpx>=0.15,<1',
|
|
'typing-extensions>=4,<5',
|
|
'python-multipart>=0.0.5',
|
|
]
|
|
|
|
swagger_ui_require = 'swagger-ui-bundle>=0.0.2,<0.1'
|
|
|
|
flask_require = [
|
|
'flask[async]>=2.2,<3',
|
|
'a2wsgi>=1.4,<2',
|
|
]
|
|
|
|
tests_require = [
|
|
'pytest>=6,<7',
|
|
'pytest-asyncio>=0.18,<0.19',
|
|
'pre-commit>=2,<3',
|
|
'pytest-cov>=2,<3',
|
|
*flask_require,
|
|
swagger_ui_require
|
|
]
|
|
|
|
docs_require = [
|
|
'sphinx-autoapi==1.8.1'
|
|
]
|
|
|
|
uvicorn_requires = [
|
|
'uvicorn[standard]>=0.17.6'
|
|
]
|
|
|
|
|
|
class PyTest(TestCommand):
|
|
|
|
user_options = [('cov-html=', None, 'Generate junit html report')]
|
|
|
|
def initialize_options(self):
|
|
TestCommand.initialize_options(self)
|
|
self.cov = None
|
|
self.pytest_args = ['--cov', 'connexion', '--cov-report', 'term-missing', '-v', "--asyncio-mode", "auto"]
|
|
self.cov_html = False
|
|
|
|
def finalize_options(self):
|
|
TestCommand.finalize_options(self)
|
|
if self.cov_html:
|
|
self.pytest_args.extend(['--cov-report', 'html'])
|
|
self.pytest_args.extend(['tests'])
|
|
|
|
def run_tests(self):
|
|
import pytest
|
|
|
|
errno = pytest.main(self.pytest_args)
|
|
sys.exit(errno)
|
|
|
|
|
|
def readme():
|
|
try:
|
|
return open('README.rst', encoding='utf-8').read()
|
|
except TypeError:
|
|
return open('README.rst').read()
|
|
|
|
|
|
setup(
|
|
name='connexion',
|
|
packages=find_packages(),
|
|
version=version,
|
|
description='Connexion - API first applications with OpenAPI/Swagger and Flask',
|
|
long_description=readme(),
|
|
author='Zalando SE',
|
|
url='https://github.com/spec-first/connexion',
|
|
keywords='openapi oai swagger rest api oauth flask microservice framework',
|
|
license='Apache License Version 2.0',
|
|
python_requires=">=3.6",
|
|
install_requires=install_requires + flask_require,
|
|
tests_require=tests_require,
|
|
extras_require={
|
|
'tests': tests_require,
|
|
'flask': flask_require,
|
|
'swagger-ui': swagger_ui_require,
|
|
'docs': docs_require,
|
|
'uvicorn': uvicorn_requires,
|
|
},
|
|
cmdclass={'test': PyTest},
|
|
test_suite='tests',
|
|
classifiers=[
|
|
'Programming Language :: Python',
|
|
'Programming Language :: Python :: 3.7',
|
|
'Programming Language :: Python :: 3.8',
|
|
'Programming Language :: Python :: 3.9',
|
|
'Programming Language :: Python :: 3.10',
|
|
'Development Status :: 5 - Production/Stable',
|
|
'Intended Audience :: Developers',
|
|
'Operating System :: OS Independent',
|
|
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
|
|
'Topic :: Software Development :: Libraries :: Application Frameworks'
|
|
],
|
|
include_package_data=True, # needed to include swagger-ui (see MANIFEST.in)
|
|
entry_points={'console_scripts': ['connexion = connexion.cli:main']}
|
|
)
|