-
Notifications
You must be signed in to change notification settings - Fork 2
feat: migrate from Connexion 2.x to 3.x while maintaining backward compatibility #10
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
avelino
wants to merge
5
commits into
main
Choose a base branch
from
avelino/migrate-connexion-2-to-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3d182e2
feat: migrate from Connexion 2.x to 3.x while maintaining backward co…
avelino 54bb3df
upgrade python 3.11 to 3.13
avelino 6e63757
fix some style issues and improvement in setup (updating)
avelino 5453236
fix test ci
avelino 935f54a
use `${{ matrix.django-version }}` variable to select the compatible …
avelino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [flake8] | ||
| max-line-length = 88 | ||
| exclude = | ||
| .git, | ||
| __pycache__, | ||
| .pytest_cache, | ||
| .coverage, | ||
| htmlcov, | ||
| venv, | ||
| build, | ||
| dist, | ||
| *.egg-info | ||
| ignore = | ||
| # Line break before binary operator (conflicts with black) | ||
| W503, | ||
| # Line break after binary operator (conflicts with black) | ||
| W504 | ||
| per-file-ignores = | ||
| # Ignore unused imports in __init__.py files | ||
| __init__.py:F401 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2022 Businho | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| .PHONY: help install install-dev test test-cov lint format check clean build docs | ||
|
|
||
| # Default target | ||
| help: | ||
| @echo "Available commands:" | ||
| @echo " install Install production dependencies" | ||
| @echo " install-dev Install development dependencies" | ||
| @echo " test Run tests without coverage" | ||
| @echo " test-cov Run tests with coverage report" | ||
| @echo " lint Run linting checks" | ||
| @echo " format Format code with black and isort" | ||
| @echo " check Run all checks (lint + test)" | ||
| @echo " clean Clean build artifacts and cache" | ||
| @echo " build Build package" | ||
| @echo " docs Generate documentation" | ||
|
|
||
| # Installation commands | ||
| install: | ||
| pip install -e . | ||
|
|
||
| install-dev: install | ||
| pip install -r requirements-dev.txt | ||
|
|
||
| # Testing commands | ||
| test: lint | ||
| python -m pytest --no-cov -v | ||
|
|
||
| test-cov: lint | ||
| python -m pytest | ||
|
|
||
| # Code quality commands | ||
| lint: | ||
| black --check django_connexion/ | ||
| isort --check-only django_connexion/ | ||
| flake8 django_connexion/ | ||
| mypy django_connexion/ --ignore-missing-imports | ||
|
|
||
| format: | ||
| black django_connexion/ | ||
| isort django_connexion/ | ||
|
|
||
| check: format lint test | ||
|
|
||
| # Cleanup commands | ||
| clean: | ||
| rm -rf build/ | ||
| rm -rf dist/ | ||
| rm -rf *.egg-info/ | ||
| rm -rf .pytest_cache/ | ||
| rm -rf htmlcov/ | ||
| rm -rf .coverage | ||
| find . -type d -name __pycache__ -exec rm -rf {} + | ||
| find . -type f -name "*.pyc" -delete | ||
|
|
||
| # Build commands | ||
| build: clean | ||
| python -m build | ||
|
|
||
| # Documentation (placeholder for future use) | ||
| docs: | ||
| @echo "Documentation generation not yet configured" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,129 @@ | ||
| ## Django Connexion | ||
| # Django Connexion | ||
|
|
||
| This is a django api for [connexion lib](https://connexion.readthedocs.io/en/latest/index.html). | ||
| Uma extensão Django para [Connexion](https://connexion.readthedocs.io/en/latest/index.html) que permite integração perfeita entre Django e especificações OpenAPI 3.x. | ||
|
|
||
| ## Get started | ||
|
|
||
| ### Install | ||
| ### Install | ||
| ## Características | ||
|
|
||
| With poetry: | ||
| ```sh | ||
| poetry add django-connexion | ||
| ``` | ||
| - 🚀 Integração nativa com Django e Connexion 3.x | ||
| - 📝 Suporte completo para especificações OpenAPI/Swagger | ||
| - 🔒 Sistema de autenticação e autorização integrado | ||
| - 🧪 Configuração moderna com `pyproject.toml` | ||
| - ✅ Código formatado com Black e verificado com Flake8/MyPy | ||
| - 📊 Cobertura de testes configurada | ||
|
|
||
| ## Instalação | ||
|
|
||
| With pip: | ||
| ```sh | ||
|
|
||
| ```bash | ||
| pip install django-connexion | ||
| ``` | ||
|
|
||
| ### Use | ||
| ## Uso Básico | ||
|
|
||
| ```python | ||
| from django_connexion import DjangoApi | ||
| from django.urls import path, include | ||
|
|
||
| # Criar API a partir da especificação OpenAPI | ||
| api = DjangoApi("openapi.yaml") # ou openapi.json | ||
|
|
||
| urlpatterns = [ | ||
| path("api/", include(api.urls)), | ||
| path("admin/", admin.site.urls), | ||
| ] | ||
| ``` | ||
|
|
||
| ## Exemplo Completo | ||
|
|
||
| ### 1. Especificação OpenAPI (`openapi.yaml`) | ||
|
|
||
| ```yaml | ||
| openapi: 3.0.0 | ||
| info: | ||
| title: Minha API | ||
| version: 1.0.0 | ||
| paths: | ||
| /hello/{name}: | ||
| post: | ||
| summary: Saudação personalizada | ||
| parameters: | ||
| - name: name | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: Sucesso | ||
| content: | ||
| text/plain: | ||
| schema: | ||
| type: string | ||
| ``` | ||
|
|
||
| ### 2. View Django (`views.py`) | ||
|
|
||
| ```python | ||
| from django.http import HttpRequest, HttpResponse | ||
|
|
||
| def post_hello(request: HttpRequest, name: str) -> HttpResponse: | ||
| return HttpResponse(f"Olá, {name}!") | ||
|
|
||
| doc_api = DjangoApi("openapi.json") # path to openapi file (json or yaml). | ||
| ``` | ||
|
|
||
| ### 3. Configuração de URLs (`urls.py`) | ||
|
|
||
| ```python | ||
| from django.urls import path, include | ||
| from django_connexion import DjangoApi | ||
|
|
||
| # ... any code | ||
| api = DjangoApi("openapi.yaml") | ||
|
|
||
| urlpatterns = [ | ||
| path("", doc_api.urls), | ||
| # ... rest of urls | ||
| path('admin/', admin.site.urls), | ||
| path("api/", include(api.urls)), | ||
| ] | ||
| ``` | ||
|
|
||
| ## Comandos Disponíveis `make` | ||
|
|
||
| ```bash | ||
| make help # Mostrar todos os comandos disponíveis | ||
| make install # Instalar dependências de produção | ||
| make install-dev # Instalar dependências de desenvolvimento | ||
| make test # Executar testes | ||
| make test-cov # Executar testes com cobertura | ||
| make lint # Verificar qualidade do código | ||
| make format # Formatar código | ||
| make check # Executar todas as verificações | ||
| make build # Construir pacote | ||
| make clean # Limpar arquivos temporários | ||
| ``` | ||
|
|
||
| ## Contribuição | ||
|
|
||
| 1. Fork o projeto | ||
| 2. Crie uma branch para sua feature (`git checkout -b feature/nova-feature`) | ||
| 3. Commit suas mudanças (`git commit -am 'Adiciona nova feature'`) | ||
| 4. Push para a branch (`git push origin feature/nova-feature`) | ||
| 5. Abra um Pull Request | ||
|
|
||
| ## Links | ||
|
|
||
| - [Documentação do Connexion](https://connexion.readthedocs.io/) | ||
| - [Documentação do Django](https://docs.djangoproject.com/) | ||
| - [Especificação OpenAPI](https://swagger.io/specification/) | ||
|
|
||
| ## Licença | ||
|
|
||
| Este projeto está licenciado sob a Licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.