Metadata-Version: 2.1
Name: edpopenapibuilder
Version: 0.0.2
Summary: E-Deploy OpenAPI Builder
Author-email: Max Guenes <max.santos@e-deploy.com.br>
Maintainer-email: Max Guenes <max.santos@e-deploy.com.br>
Requires-Python: <4,>=3.8
Description-Content-Type: text/markdown
Requires-Dist: PyYAML==6.0.3
Requires-Dist: StrEnum==0.4.15
Provides-Extra: dependencyinjection
Requires-Dist: DiHttpMessageProcessor~=1.1.0; extra == "dependencyinjection"
Requires-Dist: DiMessageProcessor~=1.0.0; extra == "dependencyinjection"

# E-Deploy Open API Builder

This project aims to provide a robust and flexible solution for automatically generating OpenAPI (Swagger) documentation for Python applications.

The `edpopenapibuilder` module is the core of this project, responsible for inspecting your Python code and generating an OpenAPI specification in YAML format. It automates the process of documenting your API endpoints, models, and request/response structures, significantly reducing the manual effort required for API documentation.

### Key Features:

- **Automatic API Discovery:** Scans application routes (injected or instance) to identify API endpoints and their associated HTTP methods.
- **Model Introspection:** Analyzes your data models to automatically generate OpenAPI schemas for request and response bodies.
- **Parameter Extraction:** Extracts path, query, header, and cookie parameters from your API routes.
- **Response Documentation:** Documents possible responses for each API endpoint, including status codes and response bodies.
- **YAML Output:** Generates a clean and human-readable OpenAPI YAML file, compatible with tools like Swagger UI and Postman.

## Usage Example

How to use `dependency injection module` to generate your OpenAPI YAML:

```python
import testhttpmodule
import edpopenapibuilder
from dependencyinjection import DependencyLoader
from dihttpmessageprocessor import AutoMappedDiRouterProcessorBuilder
from edpopenapibuilder.interactor.dto import AutoOpenApiYamlBuilderRequest
from edpopenapibuilder.interactor.injection import DependencyInjectionApiYamlBuilderInteractor

dependencies_loader = DependencyLoader()
dependencies_loader.load_modules(
    modules=[
        samplehttpmodule, # Your module containing API routes and models
        edpopenapibuilder, # The openapi builder will be loaded and injected
    ],
)

router_processor_builder = AutoMappedDiRouterProcessorBuilder(
    dependency_context=dependencies_loader.build_context(),
)

```

Or can be appended to the current routes defintions

```python

from edpopenapibuilder.route import append_open_api_build_route

routes_definitions = {
    Route("GET", "/allTypes"): AutoMappedMessageProcessor(
        interactor_type=AllTypesInteractor,
        request_type=AllTypesDto,
    ),
}


routes_definitions = append_open_api_build_route(routes_definitions)

message_handler = HttpMessageProcessorMessageHandler(routes_definitions)

```


The Open API route will be available

```HTTP
GET {HOST}/oas/yaml
```
