Skip to content

Commit 6f4e76f

Browse files
authored
Merge pull request #222 from SOHELAHMED7/163-add-or-document-how-to-read-schema-properties
Resolve: Add (or document how to) read schema properties
2 parents 845ed06 + 6788b09 commit 6f4e76f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ foreach($openapi->paths as $path => $definition) {
122122
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).
123123
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).
124124

125+
Read a component schema and its properties for below spec:
126+
127+
```yaml
128+
openapi: 3.0.0
129+
info:
130+
title: Test API
131+
version: 1.0.0
132+
paths:
133+
/foo:
134+
put:
135+
description: create foo
136+
responses:
137+
'200':
138+
description: request succeeded
139+
components:
140+
schemas:
141+
Foo:
142+
description: This is an description
143+
type: object
144+
properties:
145+
message:
146+
type: string
147+
code:
148+
type: number
149+
```
150+
151+
```php
152+
# read a component schema
153+
$foo = $openapi->components->schemas['Foo'];
154+
155+
# read a property of schema
156+
$foo->properties['message']
157+
```
158+
125159
### Writing API Description Files
126160

127161
```php

0 commit comments

Comments
 (0)