Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .flake8
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
38 changes: 25 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,37 @@ name: Python CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:

test:
name: Tests
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
django-version: ["3.2", "4.2", "5.2"]
exclude:
# Django 3.2 doesn't support Python 3.12+
- python-version: "3.12"
django-version: "3.2"
- python-version: "3.13"
django-version: "3.2"

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run Tests
run: |
python setup.py test
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "django==${{ matrix.django-version }}"

make install-dev
- name: Run tests
run: make check
21 changes: 21 additions & 0 deletions LICENSE
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.
61 changes: 61 additions & 0 deletions Makefile
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"
110 changes: 103 additions & 7 deletions README.md
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.
Loading