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

Feature/quart #3

Closed
wants to merge 13 commits into from
Closed

Feature/quart #3

wants to merge 13 commits into from

Conversation

Ruwann
Copy link
Owner

@Ruwann Ruwann commented Jan 28, 2021

Changes proposed in this pull request:

Copy link

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

There's a lot of code duplication between the Flask & Quart implementation, so it might be good to make this code reusable.

Did you already run Connexion with a Quart backend? Would be great to add it as an example.

We probably also want to add tests for Quart, similar to the ones for AioHttp.

logger = logging.getLogger('connexion.apis.quart_api')


class QuartApi(AbstractAPI):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of methods in here that are identical to the FlaskApi. You might want to extract those into a super class, or subclass from the FlaskAPI.

If there are changes, it's often just a difference between using flask or quart, so you could make the framework a property of the class that you can override.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also the case for the other classes in quart_api.py and quart_app.py.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a go at this but couldn't immediately get it to work, probably I'm trying to do it in the wrong way.

I added a new FlaskLikeApi class with a class atribute framework = None.
Then, FlaskApi inherits from FlaskLikeApi and the framework is set to flask, but this raised an error in the parent class because for example a method uses self.framework.json, giving an AttributeError.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say without looking at the code. But we can continue like this for now and try to refactor once everything works.

connexion/apps/quart_app.py Show resolved Hide resolved
@Ruwann
Copy link
Owner Author

Ruwann commented Feb 17, 2021

I added an example for Quart as well, you can also specify server='uvicorn' in the QuartApp creation.

However, there seems to be an issue if aiohttp is not installed because it is imported in connexion.security.__init__.py, but it's not directly related to Quart itself.

@Ruwann Ruwann closed this Jun 11, 2023
@Ruwann Ruwann deleted the feature/quart branch August 29, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants