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

Extract Swagger UI functionality into middleware #1496

Merged
merged 3 commits into from
Apr 10, 2022

Conversation

RobbeSneyders
Copy link
Member

Part of #1489

This PR extracts the Swagger UI functionality into a middleware.

The middleware is implemented with a starlette router on which the swagger ui endpoints are registered. For all other routes, the router acts ass a pass-through.

@RobbeSneyders RobbeSneyders added this to the Connexion 3.0 milestone Mar 17, 2022
@RobbeSneyders RobbeSneyders requested a review from Ruwann March 17, 2022 22:34
@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch 2 times, most recently from 9222986 to 2980818 Compare March 18, 2022 07:35
@RobbeSneyders RobbeSneyders force-pushed the feature/sync-async-security branch from d286806 to 7b3f883 Compare March 18, 2022 13:54
@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch from 2980818 to db12393 Compare March 18, 2022 13:56
@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch from 2de9894 to 5afdf1b Compare March 31, 2022 19:00
@RobbeSneyders RobbeSneyders changed the base branch from feature/sync-async-security to main March 31, 2022 19:00
@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch from 5afdf1b to f67a8dd Compare March 31, 2022 19:25
@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch from f67a8dd to bbeb817 Compare March 31, 2022 19:45
@RobbeSneyders
Copy link
Member Author

This one is ready for review @Ruwann

@coveralls
Copy link

coveralls commented Mar 31, 2022

Pull Request Test Coverage Report for Build 2144275390

  • 125 of 129 (96.9%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 93.3%

Changes Missing Coverage Covered Lines Changed/Added Lines %
connexion/middleware/base.py 6 7 85.71%
connexion/middleware/swagger_ui.py 77 80 96.25%
Totals Coverage Status
Change from base Build 2072604820: 0.2%
Covered Lines: 2618
Relevant Lines: 2806

💛 - Coveralls

@@ -32,7 +32,83 @@ def __init__(cls, name, bases, attrs):
cls._set_jsonifier()


class AbstractAPI(metaclass=AbstractAPIMeta):
class AbstractSpecAPI(metaclass=AbstractAPIMeta):
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a docstring for clarity on what the purpose of this class is?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

We can probably remove some of these abstract API classes in the future, since they'll only be implemented for their respective middleware. For now I've kept them so it's clear which functionality is extracted from the AbstractAPI class.

@RobbeSneyders RobbeSneyders force-pushed the feature/swagger-ui-middleware branch from e05322a to f535806 Compare April 10, 2022 15:04
@RobbeSneyders RobbeSneyders merged commit 41c19c1 into main Apr 10, 2022
@RobbeSneyders RobbeSneyders deleted the feature/swagger-ui-middleware branch April 10, 2022 15:15
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.

3 participants