An open API service indexing awesome lists of open source software.

https://github.com/jdifool/tempest-openapi-tools

OpenAPI specification generator and interactive documentation UI for the Tempest framework.
https://github.com/jdifool/tempest-openapi-tools

openapi php scalar swagger-ui tempest

Last synced: 19 days ago
JSON representation

OpenAPI specification generator and interactive documentation UI for the Tempest framework.

Awesome Lists containing this project

README

          

# OpenAPI tools for Tempest PHP

OpenAPI specification generator and interactive documentation UI for the Tempest framework.

## Requirements

- PHP 8.4+
- Tempest framework v2.0

## Installation

```bash
composer require jdifool/tempest-openapi-tools
```

## Features

- Generate OpenAPI specification from PHP code annotations using [zircote/swagger-php](https://github.com/zircote/swagger-php)
- Serve OpenAPI spec dynamically via HTTP endpoint
- Interactive API documentation with Swagger UI or Scalar

## Usage

### Command Line

Generate an OpenAPI specification file:

```bash
./tempest openapi:generate
./tempest openapi:generate --path=src --output=public/openapi.json
```

### HTTP Endpoints

The package registers two routes (configurable):

| Route | Description |
|-------|-------------|
| `/documentation/openapi.json` | OpenAPI specification (JSON) |
| `/documentation/openapi` | Interactive API documentation UI |

## Configuration

Create `openapi.config.php` in your project:

```php




HTML;
}
}
```

## Custom Route Attributes

This package provides custom Tempest route attributes that read their paths from `OpenApiConfig`:

| Attribute | Description |
|-----------|-------------|
| `#[OpenApiSpecRoute]` | Route for OpenAPI JSON specification |
| `#[OpenApiUiRoute]` | Route for interactive documentation UI |

You can use these attributes in your own controllers if needed:

```php