Skip to content

Commit 7dec313

Browse files
committed
update README.md
1 parent ded2305 commit 7dec313

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ You can switch the interface dynamically using the `ui` query parameter:
9898
## Usage
9999

100100
### 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.
102103

103104
**Example `src/Swagger/info.yaml`:**
104105
```yaml
@@ -123,17 +124,25 @@ documentation:
123124
You can define your documentation programmatically using PHP classes. This offers strong typing and IDE autocompletion.
124125

125126
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.
128135

129136
**Example `src/ApiDoc/UserDocConfig.php`:**
130137
```php
131138
<?php
132139
namespace App\ApiDoc;
133140
141+
use Ehyiah\ApiDocBundle\Attributes\ApiDocComponent;
134142
use Ehyiah\ApiDocBundle\Builder\ApiDocBuilder;
135143
use Ehyiah\ApiDocBundle\Interfaces\ApiDocConfigInterface;
136144
145+
#[ApiDocComponent(id: 'api_user_by_id')]
137146
class UserDocConfig implements ApiDocConfigInterface
138147
{
139148
public function configure(ApiDocBuilder $builder): void
@@ -155,8 +164,6 @@ class UserDocConfig implements ApiDocConfigInterface
155164
}
156165
```
157166

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-
160167
📚 **[Read full PHP Config Documentation](docs/PHP_CONFIG_CLASSES.md)**
161168
📚 **[Read the PHP Builder Reference](docs/BUILDER_REFERENCE.md)**
162169

0 commit comments

Comments
 (0)