Skip to content

Commit

Permalink
Add basic sample to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Dec 21, 2023
1 parent 3c5337b commit c9c40ea
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ openapi:
- Example: `#[Property(minLength: 3, maxLength: 255)]`
- [x] Serialize controller response (JSON format by default)

## Basic Sample

Define your OpenAPI spec and endpoint at the same time:

```php
<?php

namespace App\Controller;

use App\Model\Product;
use OpenSolid\OpenApiBundle\Attribute\Body;
use OpenSolid\OpenApiBundle\Routing\Attribute\Post;

class PostProductEndpoint
{
#[Post('/products')]
public function handle(#[Body] PostProductBody $body): Product
{
return new Product($body->name);
}
}
```

## License

This software is published under the [MIT License](LICENSE)

0 comments on commit c9c40ea

Please sign in to comment.