Skip to content

Fixes issue where register_api isn't idempotent #230

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zakmatik
Copy link

@zakmatik zakmatik commented Jun 27, 2025

In a situation where we may instantiate multiple apps that register the same blueprint, this change updates register_api to always update the APIBlueprint's instance variables to the same values no matter how many times it is invoked.

Checklist:

  • Run pytest tests and no failed.
  • Run ruff check flask_openapi3 tests examples and no failed.
  • Run mypy flask_openapi3 and no failed.
  • Run mkdocs serve and no failed.

For the fix here, I opted to update an additional field in the api rather than not updating the API because I thought that it would be helpful to have the proper updated api.paths field. I'm open to other approaches as well!

In a situation where we may instantiate multiple apps that register the
same blueprint, this change updates register_api to always update the
APIBlueprint's instance variables to the same values no matter how many
times it is invoked.
@luolingchun
Copy link
Owner

@zakmatik Thank you for your contribution, but register_api_view need this logic as well.

@zakmatik
Copy link
Author

@luolingchun Thanks for the heads up! I went ahead and also implemented for APIView and added another test. Not sure if eventually it makes sense to refactor those functions into a single "path calculation" function, but for now I kept it simple and just updated both places.

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