Skip to content

Commit

Permalink
[UNSTABLE] [Dependencies] Apply changes required by the upgrade of Co…
Browse files Browse the repository at this point in the history
…nnexion to version 3.1.x.

Signed-off-by: Giacomo Marciani <[email protected]>
  • Loading branch information
gmarciani committed Nov 27, 2024
1 parent 05f3d74 commit aa613f3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cli/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ aws-cdk.core~=1.164
aws_cdk.aws-cloudwatch~=1.164
aws_cdk.aws-lambda~=1.164
boto3>=1.16.14
connexion~=3.1
connexion~=3.1.0
flask>=2.2.5,<2.3
a2wsgi~=1.10.7
jinja2~=3.0
jmespath~=0.10
jsii==1.85.0
Expand Down
1 change: 1 addition & 0 deletions cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def readme():
"werkzeug==3.1.3",
"connexion~=3.1",
"flask>=2.2.5,<2.3",
"a2wsgi~=1.10.7",
"jmespath~=0.10",
"jsii==1.85.0",
]
Expand Down
7 changes: 4 additions & 3 deletions cli/src/pcluster/api/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import datetime

import six
from connexion.apps.flask_app import FlaskJSONEncoder
from connexion.apps.flask import Jsonifier

from pcluster.api.models.base_model_ import Model
from pcluster.utils import to_iso_timestr


class JSONEncoder(FlaskJSONEncoder):
class JSONEncoder(Jsonifier):
"""Make the model objects JSON serializable."""

include_nulls = False
Expand All @@ -34,5 +34,6 @@ def default(self, obj): # pylint: disable=arguments-renamed
dikt[attr] = value
return dikt
elif isinstance(obj, datetime.date):
# FIXME Expected type 'datetime', got 'date' instead. This issue exists before the upgrade from Connexion 2 to Connexion 3
return to_iso_timestr(obj)
return FlaskJSONEncoder.default(self, obj)
return Jsonifier.default(self, obj)
4 changes: 2 additions & 2 deletions cli/src/pcluster/api/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import connexion
from connexion import ProblemException
from connexion.decorators.validation import ParameterValidator
from connexion.validators.parameter import ParameterValidator
from flask import Response, jsonify, request
from werkzeug.exceptions import HTTPException

Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, swagger_ui: bool = False, validate_responses=False):
assert_valid_node_js()
options = {"swagger_ui": swagger_ui}

self.app = connexion.FlaskApp(__name__, specification_dir="openapi/", skip_error_handlers=True)
self.app = connexion.FlaskApp(__name__, specification_dir="openapi/")
self.flask_app = self.app.app
self.flask_app.json_encoder = encoder.JSONEncoder
self.app.add_api(
Expand Down

0 comments on commit aa613f3

Please sign in to comment.