Skip to content

feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility#10

Open
avelino wants to merge 5 commits into
mainfrom
avelino/migrate-connexion-2-to-3
Open

feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility#10
avelino wants to merge 5 commits into
mainfrom
avelino/migrate-connexion-2-to-3

Conversation

@avelino

@avelino avelino commented Jun 30, 2025

Copy link
Copy Markdown

This commit upgrades django-connexion to work with Connexion 3.x while preserving the same consumer API. The migration includes:

  • Direct OpenAPI specification parsing instead of relying on Connexion's AbstractAPI
  • Reimplemented DjangoApi class with backward-compatible interface
  • Enhanced security handler factory for Connexion 3.x architecture
  • Improved error handling and logging throughout the codebase
  • Added support for YAML and JSON OpenAPI specifications
  • Maintained the same URL pattern generation and Django integration
  • Updated version to 0.0.3 and dependency requirements

The consumer API remains unchanged, ensuring existing applications can upgrade seamlessly without modifying their integration code.

fixed: #11

…mpatibility

This commit upgrades django-connexion to work with Connexion 3.x while preserving
the same consumer API. The migration includes:

- Direct OpenAPI specification parsing instead of relying on Connexion's AbstractAPI
- Reimplemented DjangoApi class with backward-compatible interface
- Enhanced security handler factory for Connexion 3.x architecture
- Improved error handling and logging throughout the codebase
- Added support for YAML and JSON OpenAPI specifications
- Maintained the same URL pattern generation and Django integration
- Updated version to 0.0.3 and dependency requirements

The consumer API remains unchanged, ensuring existing applications can upgrade
seamlessly without modifying their integration code.

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
@avelino avelino changed the title feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility WIP: feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility Jun 30, 2025
avelino added 3 commits June 30, 2025 17:37
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
@avelino avelino changed the title WIP: feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility Jun 30, 2025
@avelino avelino requested a review from Copilot June 30, 2025 23:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the project to support Connexion 3.x while preserving backward compatibility for existing consumers. Key changes include reimplementing the DjangoApi class with direct OpenAPI specification parsing, enhancing the security handler factory for the new Connexion architecture, and modernizing configuration files (pyproject.toml, requirements-dev.txt, GitHub workflows).

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
setup.py, setup.cfg Removed in favor of the modern pyproject.toml configuration
requirements-dev.txt, pyproject.toml, .github workflows Updated dependency management and CI configuration
django_connexion/tests/* Adjustments in tests for improved type hints and consistent formatting
django_connexion/security/django_security_handler_factory.py Reimplemented security handler factory with enhanced logging
django_connexion/apis/django_api.py Refactored the DjangoApi, URL pattern generation, and response handling
README.md, Makefile, .flake8, LICENSE Updated documentation and tooling configurations

Comment on lines +346 to +350
json_getter=lambda: (
request.content_type == "application/json" and json.loads(body)
if body
else None
),

Copilot AI Jun 30, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The inline conditional expression used in the json_getter lambda is somewhat hard to read. Consider refactoring it into a separate helper function or using a clearer conditional structure.

Suggested change
json_getter=lambda: (
request.content_type == "application/json" and json.loads(body)
if body
else None
),
json_getter=lambda: cls._get_json_body(request, body),

Copilot uses AI. Check for mistakes.
Comment on lines +312 to +313
# Replace underscores with hyphens if needed
converted[key] = value

Copilot AI Jun 30, 2025

Copy link

Choose a reason for hiding this comment

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

The comment suggests converting underscores to hyphens in path parameters, but the implementation currently just copies the value without modification. If this transformation is intended, please implement the conversion or update the comment accordingly.

Suggested change
# Replace underscores with hyphens if needed
converted[key] = value
# Replace underscores with hyphens in keys
converted[key.replace("_", "-")] = value

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/python.yml Outdated
@ecarrara

ecarrara commented Jul 1, 2025

Copy link
Copy Markdown

I support the idea of improving the development experience by adding linting, type checking, Makefile-like task runners, and other configurations. However, I think these changes should be introduced in separate PRs.

…django version

Co-authored-by: Erle Carrara <carrara.erle@gmail.com>
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.

update connexion version to 3

3 participants