Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ApiV1_1 extends ApiV1 {
*/
```

**Templates** are enabled via `$useResponseTemplates = true` on the Api class. `getSchemaTemplates()` / `getSecuritySchemes()` are the neutral names of `getOpenApiTemplates()` / `getOpenApiSecurityDefinitions()`: package code calls the neutral ones (which default to the old ones); users may override either. Keep docs examples on the old names until the IDE plugin (`../laravel-api-idea`, hardcodes the old names in TemplateLookup/TemplateUsages/SecurityLookup/CreateTemplateFix) supports the new ones.
**Templates** are enabled via `$useResponseTemplates = true` on the Api class. Templates and security schemes are declared in `getSchemaTemplates()` / `getSecuritySchemes()` (since 6.1); `getOpenApiTemplates()` / `getOpenApiSecurityDefinitions()` are their earlier names and keep working — package code calls the new ones, which default to the old ones. Docs and lint hints use the new names; test fixtures keep the old ones on purpose (they cover the fallback). The IDE plugin (`../laravel-api-idea`) reads both since 1.1.0 (`ApiHooks`).

Shorthand string syntax (recommended):
```
Expand All @@ -191,7 +191,7 @@ Both shorthand and array formats can be mixed in the same template.
class Api extends BaseApi {
public static bool $useResponseTemplates = true;

public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
// Shorthand syntax
'UserResponse' => [
Expand All @@ -207,7 +207,7 @@ class Api extends BaseApi {
];
}

public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => [
'type' => 'apiKey',
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- The documentation and the `api:lint` hints use `getSchemaTemplates()` and
`getSecuritySchemes()`. `getOpenApiTemplates()` and
`getOpenApiSecurityDefinitions()` keep working; the IDE plugin reads both
names from 1.1.0.

## [6.1.0] — 2026-10-26

The API is now read through one model of its operations: `getMethods()` in one
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Enable reusable schemas via `components/schemas`:
class Api extends BaseApi {
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
'OrderResponse' => [
'id' => 'integer!', // required integer
Expand All @@ -394,15 +394,15 @@ class Api extends BaseApi {
];
}

public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => ['type' => 'apiKey', 'name' => 'Authorization', 'in' => 'header'],
];
}
}
```

**Neutral names.** `getSchemaTemplates()` and `getSecuritySchemes()` are the same hooks under names that are not about OpenAPI — the templates describe payloads whatever carries them. Override either name; the package reads the neutral one, which answers with the OpenAPI-era hook unless overridden itself. The examples here keep the OpenAPI-era names until the [IDE plugin](#ide-support) reads the neutral ones too.
**Names before 6.1.** `getOpenApiTemplates()` and `getOpenApiSecurityDefinitions()` keep working: they are the same hooks under their earlier names. Override either name; the package reads `getSchemaTemplates()` / `getSecuritySchemes()`, which answer with the earlier ones unless overridden themselves. The [IDE plugin](#ide-support) reads both names from 1.1.0.

**Shorthand syntax reference:**

Expand Down Expand Up @@ -703,7 +703,7 @@ publish that for Community.
writes the tag from it — `email` becomes `string(email)`, a rule that is not
`required` becomes optional, `in:a,b` becomes an enumeration.
- Marks a `@response` template or a `@security` scheme nothing declares, and
offers to declare the template — creating `getOpenApiTemplates()` when the
offers to declare the template — creating `getSchemaTemplates()` when the
class has none.
- Turns the silent 404 red: an action pointing at a missing, non-public or
static method is an error while typing, with a quick fix that writes the
Expand Down Expand Up @@ -981,7 +981,7 @@ Dskripchenko\LaravelApi\Middlewares\RequestIdMiddleware::class

| Class | Methods |
|-------|---------|
| `BaseApi` (all methods are `static`) | `getMethods()`, `make()`, `getOpenApiTemplates()` / `getSchemaTemplates()`, `getOpenApiSecurityDefinitions()` / `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseApi` (all methods are `static`) | `getMethods()`, `make()`, `getSchemaTemplates()`, `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseModule` | `getApi($version)`, `makeApi()`, `getApiVersionList()`, `getApiPrefix()`, `getApiUriPattern()`, `getAvailableApiMethods()`, `getDocMiddleware()` |
| `Meta` | `string($key, $name)`, `integer($key, $name)`, `number($key, $name)`, `boolean($key, $name)`, `hidden($key, $name)`, `select($key, $name, $items)`, `file($key, $name, $src)`, `action($key, $condition)`, `crud()`, `getOpenApiInputs()`, `getColumnKeys()` |

Expand Down
10 changes: 5 additions & 5 deletions docs/de/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Wiederverwendbare Schemas aktivieren über `components/schemas`:
class Api extends BaseApi {
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
'OrderResponse' => [
'id' => 'integer!', // Pflichtfeld Integer
Expand All @@ -380,15 +380,15 @@ class Api extends BaseApi {
];
}

public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => ['type' => 'apiKey', 'name' => 'Authorization', 'in' => 'header'],
];
}
}
```

**Neutrale Namen.** `getSchemaTemplates()` und `getSecuritySchemes()` sind dieselben Hooks unter Namen, die nicht an OpenAPI hängen — Templates beschreiben Payloads, egal wodurch sie übertragen werden. Überschreiben Sie einen der beiden Namen; das Paket liest den neutralen, der ohne eigene Überschreibung den alten Hook beantwortet. Die Beispiele hier bleiben bei den alten Namen, bis das IDE-Plugin die neutralen ebenfalls liest.
**Namen vor 6.1.** `getOpenApiTemplates()` und `getOpenApiSecurityDefinitions()` funktionieren weiter: Es sind dieselben Hooks unter ihren früheren Namen. Überschreiben Sie einen der beiden Namen; das Paket liest `getSchemaTemplates()` / `getSecuritySchemes()`, die ohne eigene Überschreibung die früheren beantworten. Das IDE-Plugin liest ab 1.1.0 beide Namen.

**Shorthand-Syntax:** `type` — optional, `type!` — Pflicht, `type(format)` — mit Format, `@Model` — Referenz, `@Model[]` — Array von Referenzen. Das Array-Format (`['type' => '...', 'required' => true]`) wird ebenfalls unterstützt.

Expand Down Expand Up @@ -801,7 +801,7 @@ das veröffentlicht JetBrains für Community nicht.
ohne `required` → optionales Feld, `in:a,b` → Aufzählung.
- Markiert ein `@response`-Template oder ein `@security`-Schema, das niemand
deklariert hat, und bietet an, das Template zu deklarieren — inklusive
`getOpenApiTemplates()`, wenn die Klasse keines hat.
`getSchemaTemplates()`, wenn die Klasse keines hat.
- Macht den stillen 404 rot: eine Action, die auf eine fehlende, nicht
öffentliche oder statische Methode zeigt, ist ein Fehler beim Tippen, mit einem
Quick-Fix, der die Methode nach dem Vorbild der Nachbarn schreibt.
Expand Down Expand Up @@ -936,7 +936,7 @@ das veröffentlicht JetBrains für Community nicht.

| Klasse | Methoden |
|-------|---------|
| `BaseApi` | `getMethods()`, `make()`, `getOpenApiTemplates()` / `getSchemaTemplates()`, `getOpenApiSecurityDefinitions()` / `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseApi` | `getMethods()`, `make()`, `getSchemaTemplates()`, `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseModule` | `getApi($version)`, `makeApi()`, `getApiVersionList()`, `getApiPrefix()`, `getApiUriPattern()`, `getAvailableApiMethods()` |
| `Meta` | `string()`, `integer()`, `number()`, `boolean()`, `hidden()`, `select()`, `file()`, `action()`, `crud()`, `getOpenApiInputs()`, `getColumnKeys()` |

Expand Down
6 changes: 3 additions & 3 deletions docs/de/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class Api extends BaseApi
{
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array
public static function getSchemaTemplates(): array
{
return [
'UserResponse' => [
Expand All @@ -389,7 +389,7 @@ class Api extends BaseApi
];
}

public static function getOpenApiSecurityDefinitions(): array
public static function getSecuritySchemes(): array
{
return [
'BearerAuth' => [
Expand Down Expand Up @@ -556,7 +556,7 @@ export interface UserShowOutput {
| `$ref` | Interface-Name |
| `enum` | `'a' \| 'b' \| 'c'` |

Komponentenschemata aus `getOpenApiTemplates()` werden als benannte Interfaces generiert. Fuer jede Operation werden `{Controller}{Action}Input`- und `{Controller}{Action}Output`-Typen erstellt.
Komponentenschemata aus `getSchemaTemplates()` werden als benannte Interfaces generiert. Fuer jede Operation werden `{Controller}{Action}Input`- und `{Controller}{Action}Output`-Typen erstellt.

---

Expand Down
10 changes: 5 additions & 5 deletions docs/de/docblock-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Erzeugt:
@input @OrderCreateRequest
```

Erzeugt `$ref: '#/components/schemas/OrderCreateRequest'` im requestBody. Das Modell muss in `getOpenApiTemplates()` definiert sein.
Erzeugt `$ref: '#/components/schemas/OrderCreateRequest'` im requestBody. Das Modell muss in `getSchemaTemplates()` definiert sein.

### Liste von Skalaren

Expand Down Expand Up @@ -316,10 +316,10 @@ Wendet ein Sicherheitsschema auf die Operation an.
@security BearerAuth
```

Das Schema muss in `getOpenApiSecurityDefinitions()` der Api-Klasse definiert sein:
Das Schema muss in `getSecuritySchemes()` der Api-Klasse definiert sein:

```php
public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => [
'type' => 'apiKey',
Expand Down Expand Up @@ -384,7 +384,7 @@ Setzt einen Beispielwert fuer einen Parameter.

## Kurzschreibweise fuer Templates

Bei der Definition von Templates in `getOpenApiTemplates()` kann eine Kurzschreibweise als String anstelle von ausfuehrlichen Arrays verwendet werden:
Bei der Definition von Templates in `getSchemaTemplates()` kann eine Kurzschreibweise als String anstelle von ausfuehrlichen Arrays verwendet werden:

| Syntax | Bedeutung | Aequivalentes Array |
|--------|---------|------------------|
Expand All @@ -403,7 +403,7 @@ Bei der Definition von Templates in `getOpenApiTemplates()` kann eine Kurzschrei
### Beispiel

```php
public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
'OrderResponse' => [
'id' => 'integer!',
Expand Down
6 changes: 3 additions & 3 deletions docs/en/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class Api extends BaseApi
{
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array
public static function getSchemaTemplates(): array
{
return [
'UserResponse' => [
Expand All @@ -389,7 +389,7 @@ class Api extends BaseApi
];
}

public static function getOpenApiSecurityDefinitions(): array
public static function getSecuritySchemes(): array
{
return [
'BearerAuth' => [
Expand Down Expand Up @@ -556,7 +556,7 @@ export interface UserShowOutput {
| `$ref` | Interface name |
| `enum` | `'a' \| 'b' \| 'c'` |

Component schemas from `getOpenApiTemplates()` are generated as named interfaces. Each operation produces `{Controller}{Action}Input` and `{Controller}{Action}Output` types.
Component schemas from `getSchemaTemplates()` are generated as named interfaces. Each operation produces `{Controller}{Action}Input` and `{Controller}{Action}Output` types.

---

Expand Down
10 changes: 5 additions & 5 deletions docs/en/docblock-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Generates:
@input @OrderCreateRequest
```

Generates `$ref: '#/components/schemas/OrderCreateRequest'` in requestBody. The model must be defined in `getOpenApiTemplates()`.
Generates `$ref: '#/components/schemas/OrderCreateRequest'` in requestBody. The model must be defined in `getSchemaTemplates()`.

### List of scalars

Expand Down Expand Up @@ -314,10 +314,10 @@ Applies a security scheme to the operation.
@security BearerAuth
```

The scheme must be defined in `getOpenApiSecurityDefinitions()` on the Api class:
The scheme must be defined in `getSecuritySchemes()` on the Api class:

```php
public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => [
'type' => 'apiKey',
Expand Down Expand Up @@ -382,7 +382,7 @@ Sets an example value for a parameter.

## Template shorthand syntax

When defining templates in `getOpenApiTemplates()`, you can use a shorthand string notation instead of verbose arrays:
When defining templates in `getSchemaTemplates()`, you can use a shorthand string notation instead of verbose arrays:

| Syntax | Meaning | Equivalent array |
|--------|---------|------------------|
Expand All @@ -401,7 +401,7 @@ When defining templates in `getOpenApiTemplates()`, you can use a shorthand stri
### Example

```php
public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
'OrderResponse' => [
'id' => 'integer!',
Expand Down
10 changes: 5 additions & 5 deletions docs/ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Schema, который попадает в спецификацию как ес
class Api extends BaseApi {
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array {
public static function getSchemaTemplates(): array {
return [
'OrderResponse' => [
'id' => 'integer!', // обязательное целое
Expand All @@ -379,15 +379,15 @@ class Api extends BaseApi {
];
}

public static function getOpenApiSecurityDefinitions(): array {
public static function getSecuritySchemes(): array {
return [
'BearerAuth' => ['type' => 'apiKey', 'name' => 'Authorization', 'in' => 'header'],
];
}
}
```

**Нейтральные имена.** `getSchemaTemplates()` и `getSecuritySchemes()` — те же хуки под именами, не привязанными к OpenAPI: шаблоны описывают payload, чем бы он ни передавался. Переопределяйте любое из имён; пакет читает нейтральное, а оно, если не переопределено, отвечает старым хуком. Примеры здесь остаются на старых именах, пока их не начнёт читать [IDE-плагин](#поддержка-ide).
**Имена до 6.1.** `getOpenApiTemplates()` и `getOpenApiSecurityDefinitions()` продолжают работать: это те же хуки под прежними именами. Переопределяйте любое из имён; пакет читает `getSchemaTemplates()` / `getSecuritySchemes()`, а они, если не переопределены, отвечают прежними. [IDE-плагин](#поддержка-ide) читает оба имени начиная с 1.1.0.

**Shorthand-синтаксис:** `type` — необязательное, `type!` — обязательное, `type(format)` — с форматом, `@Model` — ссылка, `@Model[]` — массив ссылок. Также поддерживается формат массивов (`['type' => '...', 'required' => true]`).

Expand Down Expand Up @@ -810,7 +810,7 @@ PhpStorm или IntelliJ IDEA Ultimate с плагином PHP. IDEA Community
из него: `email` → `string(email)`, правило без `required` → необязательное
поле, `in:a,b` → перечисление.
- Отмечает шаблон `@response` или схему `@security`, которых никто не объявлял,
и предлагает объявить шаблон — заведя `getOpenApiTemplates()`, если метода нет.
и предлагает объявить шаблон — заведя `getSchemaTemplates()`, если метода нет.
- Делает молчаливую 404 красной: действие, указывающее на отсутствующий,
непубличный или статический метод, — ошибка прямо при наборе, с быстрым
исправлением, которое пишет метод по образцу соседей.
Expand Down Expand Up @@ -944,7 +944,7 @@ PhpStorm или IntelliJ IDEA Ultimate с плагином PHP. IDEA Community

| Класс | Методы |
|-------|---------|
| `BaseApi` | `getMethods()`, `make()`, `getOpenApiTemplates()` / `getSchemaTemplates()`, `getOpenApiSecurityDefinitions()` / `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseApi` | `getMethods()`, `make()`, `getSchemaTemplates()`, `getSecuritySchemes()`, `operations()`, `beforeCallAction()`, `afterCallAction()`, `getMiddleware()` |
| `BaseModule` | `getApi($version)`, `makeApi()`, `getApiVersionList()`, `getApiPrefix()`, `getApiUriPattern()`, `getAvailableApiMethods()` |
| `Meta` | `string()`, `integer()`, `number()`, `boolean()`, `hidden()`, `select()`, `file()`, `action()`, `crud()`, `getOpenApiInputs()`, `getColumnKeys()` |

Expand Down
6 changes: 3 additions & 3 deletions docs/ru/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class Api extends BaseApi
{
public static $useResponseTemplates = true;

public static function getOpenApiTemplates(): array
public static function getSchemaTemplates(): array
{
return [
'UserResponse' => [
Expand All @@ -389,7 +389,7 @@ class Api extends BaseApi
];
}

public static function getOpenApiSecurityDefinitions(): array
public static function getSecuritySchemes(): array
{
return [
'BearerAuth' => [
Expand Down Expand Up @@ -556,7 +556,7 @@ export interface UserShowOutput {
| `$ref` | Имя интерфейса |
| `enum` | `'a' \| 'b' \| 'c'` |

Схемы компонентов из `getOpenApiTemplates()` генерируются как именованные интерфейсы. Для каждой операции создаются типы `{Controller}{Action}Input` и `{Controller}{Action}Output`.
Схемы компонентов из `getSchemaTemplates()` генерируются как именованные интерфейсы. Для каждой операции создаются типы `{Controller}{Action}Input` и `{Controller}{Action}Output`.

---

Expand Down
Loading
Loading