Skip to content

Commit

Permalink
Merge pull request #222 from SOHELAHMED7/163-add-or-document-how-to-r…
Browse files Browse the repository at this point in the history
…ead-schema-properties

Resolve: Add (or document how to) read schema properties
  • Loading branch information
cebe authored Feb 7, 2025
2 parents 845ed06 + 6788b09 commit 6f4e76f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,40 @@ foreach($openapi->paths as $path => $definition) {
Object properties are exactly like in the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#openapi-specification).
You may also access additional properties added by [specification extensions](https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#specificationExtensions).

Read a component schema and its properties for below spec:

```yaml
openapi: 3.0.0
info:
title: Test API
version: 1.0.0
paths:
/foo:
put:
description: create foo
responses:
'200':
description: request succeeded
components:
schemas:
Foo:
description: This is an description
type: object
properties:
message:
type: string
code:
type: number
```
```php
# read a component schema
$foo = $openapi->components->schemas['Foo'];

# read a property of schema
$foo->properties['message']
```

### Writing API Description Files

```php
Expand Down

0 comments on commit 6f4e76f

Please sign in to comment.