Comments (4)
Weirdly enough, I'm here for the exact same reason. How do I read for instance all of the expected responses for a given path?
I got this far:
foreach($openapi->paths as $path => $definition) {
foreach($definition->get->responses as $code => $response){
var_dump($code);
var_dump($response->get);
}
}
But this will result in the below, and I'm a little stuck how to get for instance the schema other than using the getSerializableData()
method, because that won't work when the value is a reference:
int(200)
object(cebe\openapi\spec\Response)#51 (10) {
["_properties":"cebe\openapi\SpecBaseObject":private]=>
array(2) {
["description"]=>
string(7) "Success"
["schema"]=>
array(2) {
["type"]=>
string(6) "string"
["example"]=>
array(2) {
["Status"]=>
string(7) "Success"
["Result"]=>
array(1) {
["credits"]=>
string(4) "5000"
}
}
}
}
(...)
}
from php-openapi.
I'm using this library to read the description and example properties from the schema, but it seem that those properties are protected.
what makes you think that? what is the code you tried? if you have a Schema object, you can access the properties by $schema->example
or $schema->description
...
How do I read for instance all of the expected responses for a given path?
Exactly as you did. What is wrong with the result? you are getting the response code int(200)
and the Response
object for it.
$response->description
should give you the description.
from php-openapi.
Again, maybe I'm not using the library right, could you add a snippet the the documentation?
$openapi = Reader::readFromJsonFile($fn = $bag->get('kernel.project_dir') . '/openapi.json');
foreach ($openapi->components->schemas as $schema) {
dd($schema);
// $properties = $schema->getProperties(); //<-- this does't work
}
from php-openapi.
@cebe I think the challenge is that at times, I won't know what property keys are available and it would be useful to have access to all of them instead of querying each one to see if they exist.
from php-openapi.
Related Issues (20)
- Infinite loop error HOT 1
- Symfony 6 support HOT 2
- Missing functions to remove elements ? HOT 1
- Referenced Parameters compiling to Object instead of Array HOT 4
- Major Performance issue even with new caching? HOT 6
- Speccy uses dompurify with XSS vulnerability HOT 5
- Add a way to create schemas HOT 1
- Reference parsing doesn't work in the CLI tool using relative paths. HOT 3
- Wrong error message when using an undefined property for a schema object property definition HOT 1
- Convert the code-base to use Symfony Console HOT 1
- Make `symfony/yaml` dependency optional
- References to incorrect components should be considered invalid HOT 1
- Unable to reference other local json file HOT 2
- Duplicate OperationIds should be considered invalid
- Support for PHP 8.1 and 8.2 HOT 1
- Further library maintenance HOT 9
- Discriminator mapping throws validation error on valid discriminator mapping and accepts incorrect one. HOT 1
- Add support for symfony/yaml version ^7 HOT 3
- Nexmo/api-specification no longer exists HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-openapi.