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

Only instantiate specification once #1819

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Conversation

RobbeSneyders
Copy link
Member

Fixes #1801

I had to make quite a few additional changes to satisfy mypy.

@coveralls
Copy link

coveralls commented Nov 24, 2023

Coverage Status

coverage: 94.231% (-0.06%) from 94.287%
when pulling 5a1e535 on bugfix/instantiate-spec-once
into bbd085b on main.

@@ -31,7 +32,7 @@ def __init__(
@classmethod
def from_operation(
cls,
operation: AbstractOperation,
operation: t.Union[AbstractOperation, Specification],
Copy link
Member

Choose a reason for hiding this comment

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

I don't immediately understand where this is coming from: why can this now be a Specification object as well? The variable name is pretty confusing now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I understand it can be confusing 😅. This is because the security is defined both on the Operation and the Specification object, since it is defined at both these levels in the spec. For normal operations, the Operation is used. But for the add_auth_on_not_found, we create a dummy SecurityOperation based on the Specification.

I will add a comment explaining this.

@@ -9,7 +9,7 @@ def post_greeting(name: str) -> str:

app = connexion.FlaskApp(__name__, specification_dir="spec/")
app.add_api("openapi.yaml", arguments={"title": "Hello World Example"})
app.add_api("swagger.yaml", arguments={"title": "Hello World Example"})
# app.add_api("swagger.yaml", arguments={"title": "Hello World Example"})
Copy link
Member

Choose a reason for hiding this comment

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

Remant from local testing?

Suggested change
# app.add_api("swagger.yaml", arguments={"title": "Hello World Example"})
app.add_api("swagger.yaml", arguments={"title": "Hello World Example"})

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

@RobbeSneyders RobbeSneyders merged commit 0857710 into main Nov 30, 2023
7 of 8 checks passed
@RobbeSneyders RobbeSneyders deleted the bugfix/instantiate-spec-once branch November 30, 2023 22:59
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.

Slowdown of cold start in connexion 3.0
3 participants