You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,8 @@ You can switch the interface dynamically using the `ui` query parameter:
98
98
## Usage
99
99
100
100
### 1. YAML Configuration
101
-
Place your OpenAPI YAML files in the directory defined by `source_path` (default: `src/Swagger`). The bundle will automatically parse and merge all `.yaml` and `.yml` files in this folder.
101
+
Place your OpenAPI YAML files in the directory defined by `source_path` (default: `src/Swagger`).
102
+
The bundle will automatically parse and merge all `.yaml` and `.yml` files in this folder.
102
103
103
104
**Example `src/Swagger/info.yaml`:**
104
105
```yaml
@@ -123,17 +124,25 @@ documentation:
123
124
You can define your documentation programmatically using PHP classes. This offers strong typing and IDE autocompletion.
124
125
125
126
1. Create a class that implements `Ehyiah\ApiDocBundle\Interfaces\ApiDocConfigInterface`.
126
-
2. Implement the `configure` method.
127
-
3. Your class is automatically autoloaded and parsed.
127
+
2. Add the `#[ApiDocComponent]` attribute with a unique `id`.
128
+
3. Implement the `configure` method.
129
+
4. Your class is automatically autoloaded and parsed.
130
+
131
+
The `#[ApiDocComponent]` attribute is **required**. It lets the TUI find and edit your component regardless of file location or class name.
132
+
133
+
- **`id`** — A unique string that identifies this component. Use the same name as the OpenAPI component key (e.g., for a schema named `User`, use `id: 'User'`). For routes, use the route name (e.g., `id: 'api_users'`).
134
+
- **`type`** — Optional. A hint for the TUI (e.g., `'schema'`, `'response'`, `'tag'`). Auto-detected in most cases.
128
135
129
136
**Example `src/ApiDoc/UserDocConfig.php`:**
130
137
```php
131
138
<?php
132
139
namespace App\ApiDoc;
133
140
141
+
use Ehyiah\ApiDocBundle\Attributes\ApiDocComponent;
134
142
use Ehyiah\ApiDocBundle\Builder\ApiDocBuilder;
135
143
use Ehyiah\ApiDocBundle\Interfaces\ApiDocConfigInterface;
136
144
145
+
#[ApiDocComponent(id: 'api_user_by_id')]
137
146
class UserDocConfig implements ApiDocConfigInterface
138
147
{
139
148
public function configure(ApiDocBuilder $builder): void
@@ -155,8 +164,6 @@ class UserDocConfig implements ApiDocConfigInterface
155
164
}
156
165
```
157
166
158
-
> 💡 **Tip:** While PHP config classes can be placed anywhere in `src/`, it is recommended to keep them in `src/Swagger` (or your `source_path`) if you want the **Generator Commands** to detect them and prevent duplicates.
159
-
160
167
📚 **[Read full PHP Config Documentation](docs/PHP_CONFIG_CLASSES.md)**
161
168
📚 **[Read the PHP Builder Reference](docs/BUILDER_REFERENCE.md)**
0 commit comments