Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies on v2 banch #1992

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
20 changes: 13 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ version: 2
sphinx:
configuration: docs/conf.py

python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
build:
os: "ubuntu-22.04"
tools:
python: "3.9"
jobs:
post_create_environment:
# Install poetry
- python -m pip install poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
# Install dependencies with 'docs' dependency group
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --with docs --all-extras
7 changes: 4 additions & 3 deletions connexion/apis/flask_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any

import flask
from flask.globals import request_ctx
import werkzeug.exceptions
from werkzeug.local import LocalProxy

Expand Down Expand Up @@ -36,7 +37,7 @@ def _set_base_path(self, base_path):

def _set_blueprint(self):
logger.debug('Creating API blueprint: %s', self.base_path)
endpoint = flask_utils.flaskify_endpoint(self.base_path)
endpoint = flask_utils.flaskify_endpoint(self.base_path) or "/"
self.blueprint = flask.Blueprint(endpoint, __name__, url_prefix=self.base_path,
template_folder=str(self.options.openapi_console_ui_from_dir))

Expand Down Expand Up @@ -233,7 +234,7 @@ def get_request(cls, *args, **params):
:rtype: ConnexionRequest
"""
context_dict = {}
setattr(flask._request_ctx_stack.top, 'connexion_context', context_dict)
setattr(request_ctx, "connexion_context", context_dict)
flask_request = flask.request
request = ConnexionRequest(
flask_request.url,
Expand Down Expand Up @@ -265,7 +266,7 @@ def _set_jsonifier(cls):


def _get_context():
return getattr(flask._request_ctx_stack.top, 'connexion_context')
return getattr(request_ctx, "connexion_context")


context = LocalProxy(_get_context)
Expand Down
29 changes: 27 additions & 2 deletions connexion/apps/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import datetime
import logging
import pathlib
import json
from decimal import Decimal
from types import FunctionType # NOQA

import flask
import werkzeug.exceptions
from flask import json, signals
from flask import signals
from flask.json.provider import DefaultJSONProvider

from ..apis.flask_api import FlaskApi
from ..exceptions import ProblemException
Expand All @@ -33,7 +35,7 @@ def __init__(self, import_name, server='flask', extra_files=None, **kwargs):

def create_app(self):
app = flask.Flask(self.import_name, **self.server_args)
app.json_encoder = FlaskJSONEncoder
app.json = FlaskJSONProvider(app)
app.url_map.converters['float'] = NumberConverter
app.url_map.converters['int'] = IntegerConverter
return app
Expand Down Expand Up @@ -150,6 +152,29 @@ def run(self,
raise Exception(f'Server {self.server} not recognized')


class FlaskJSONProvider(DefaultJSONProvider):
def __init__(self, app):
super().__init__(app)

def default(self, o):
if isinstance(o, datetime.datetime):
if o.tzinfo:
# eg: '2015-09-25T23:14:42.588601+00:00'
return o.isoformat("T")
else:
# No timezone present - assume UTC.
# eg: '2015-09-25T23:14:42.588601Z'
return o.isoformat("T") + "Z"

if isinstance(o, datetime.date):
return o.isoformat()

if isinstance(o, Decimal):
return float(o)

return super().default(o)


class FlaskJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime.datetime):
Expand Down
8 changes: 4 additions & 4 deletions connexion/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from typing import Optional # NOQA

try:
from swagger_ui_bundle import swagger_ui_2_path, swagger_ui_3_path
from swagger_ui_bundle import swagger_ui_path as default_template_dir
except ImportError:
swagger_ui_2_path = swagger_ui_3_path = None
default_template_dir = None

from connexion.decorators.uri_parsing import AbstractURIParser

Expand All @@ -28,10 +28,10 @@ def __init__(self, options=None, oas_version=(2,)):
self.oas_version = oas_version
if self.oas_version >= (3, 0, 0):
self.openapi_spec_name = '/openapi.json'
self.swagger_ui_local_path = swagger_ui_3_path
self.swagger_ui_local_path = default_template_dir
else:
self.openapi_spec_name = '/swagger.json'
self.swagger_ui_local_path = swagger_ui_2_path
self.swagger_ui_local_path = default_template_dir

if options:
self._options.update(filter_values(options))
Expand Down
49 changes: 31 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['autoapi.extension']

autoapi_type = 'python'
autoapi_options = ['members',
'inherited-members',
'undoc-members',
'show-inheritance',
'show-module-summary',
'special-members',
'imported-members']
autoapi_python_class_content = 'both'
autoapi_dirs = [
'../connexion'
extensions = [
'sphinx.ext.autodoc',
'sphinx_copybutton',
'sphinx_design',
'sphinx.ext.autosectionlabel',
'sphinxemoji.sphinxemoji',
]
autosectionlabel_prefix_document = True

autoclass_content = 'both'

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -62,11 +58,12 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import connexion
# The short X.Y version.
version = connexion.__version__.rsplit('.', 1)[0]
from importlib.metadata import version

# The full version, including alpha/beta/rc tags.
release = connexion.__version__
release = version('connexion')
# The short X.Y version.
version = release.rsplit('.', 1)[0]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -117,6 +114,18 @@
html_theme = "sphinx_rtd_theme"

html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_theme_options = {
'navigation_depth': 2
}

html_context = {
'display_github': True,
'github_user': 'spec-first',
'github_repo': 'connexion',
'github_version': 'main',
'conf_py_path': '/docs/'
}
except:
pass

Expand Down Expand Up @@ -147,7 +156,11 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
html_static_path = ['_static']

html_css_files = [
'css/default.css',
]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down
Loading
Loading