Skip to content

Commit 183e8ef

Browse files
committed
docs: better example
1 parent be4f777 commit 183e8ef

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,25 @@ $ git clone https://github.com/erasys/openapi-php.git
4040

4141
## Usage
4242

43+
Basic example:
44+
4345
```php
4446
<?php
4547

4648
use erasys\OpenApi\Spec\v3 as OASv3;
4749

4850
$spec = new OASv3\Document(
49-
new OASv3\Info('My API', '1.0.0', '[description]', '[license]')
51+
new OASv3\Info('My API', '1.0.0', 'My API description', 'My License')
5052
);
5153

52-
$spec->security = [
53-
['api_key' => []]
54+
$rootPath = new OASv3\PathItem();
55+
$rootPath->get = new OASv3\Operation();
56+
$rootPath->get->responses = [
57+
'200' => new OASv3\Response(['description' => 'successful response'])
5458
];
5559

60+
$spec->paths = ['/' => $rootPath];
61+
5662
$yaml = $spec->toYaml();
5763
$json = $spec->toJson();
5864
$arr = $spec->toArray();

0 commit comments

Comments
 (0)