File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -195,9 +195,20 @@ references to structures in external files, we must provide the full context.
195
195
196
196
``` php
197
197
use cebe\openapi\Reader;
198
+ use cebe\openapi\spec\OpenAPI;
199
+ use cebe\openapi\ReferenceContext;
200
+
201
+ // there are two different modes for resolving references:
202
+ // ALL: resolve all references, which will result in a large description with a lot of repetition
203
+ // but no references (except if there are recursive references, these will stop at some level)
204
+ $mode = ReferenceContext::RESOLVE_MODE_ALL;
205
+ // INLINE: only references to external files are resolved, references to places in the current file
206
+ // are still Reference objects.
207
+ $mode = ReferenceContext::RESOLVE_MODE_INLINE;
208
+
198
209
// an absolute URL or file path is needed to allow resolving external references
199
- $openapi = Reader::readFromJsonFile('https://www.example.com/api/openapi.json');
200
- $openapi = Reader::readFromYamlFile('https://www.example.com/api/openapi.yaml');
210
+ $openapi = Reader::readFromJsonFile('https://www.example.com/api/openapi.json', OpenAPI::class, $mode );
211
+ $openapi = Reader::readFromYamlFile('https://www.example.com/api/openapi.yaml', OpenAPI::class, $mode );
201
212
```
202
213
203
214
If data has been loaded in a different way you can manually resolve references like this by giving a context:
You can’t perform that action at this time.
0 commit comments