Comments (6)
I was pointed to this: https://github.com/Rarst/wporg-client/blob/33fb0dcce9f170b92824d09f5717ca814d7ecd29/php/WporgService.php and it worked for me :)
from guzzle-services.
Still, I don't see why the first approach should not work. I mean clearly the outer structure should be marked as an array, but then this array consists of the given models.
This maybeToArray seems like a very odd solution to me...
from guzzle-services.
I know, but in the absence of any decent documentation this was the only solution I could find. If you could find a better solution, I would love to see it 😄
from guzzle-services.
Hey ... just figured it out. You need to use "location" => "json" on the array definition. So for my use case this works
$description = new Description([
'baseUrl' => 'http://localhost',
'operations' => [
'facets' => [
'httpMethod' => 'GET',
'uri' => 'fakeapi/facets.json',
'responseModel' => 'Facets',
],
'facet' => [
'httpMethod' => 'GET',
'uri' => 'fakeapi/facet.json',
'responseModel' => 'Facet'
]
],
'models' => [
"Facet" => [
"type" => "object",
"properties" => [
"id" => [
"location" => "json",
"type" => "int"
],
"group_name" => [
"location" => "json",
"type" => "string"
],
"name" => [
"location" => "json",
"type" => "string"
],
"facet_id" => [
"location" => "json",
"type" => "int"
],
]
],
'Facets' => [
"type" => "array",
"location" => "json",
"items" => [
"type" => "object",
'$ref' => "Facet"
]
]
]
]);
$guzzle = new GuzzleClient($client, $description);
$command = $guzzle->getCommand('facets');
$result = $guzzle->execute($command);
Data in facet.json is
{
"id": 257,
"group_name": "material",
"name": "Foo",
"value": "Bar",
"facet_id": 3606
}
and facets.json is an array of these
from guzzle-services.
I did not succeed to use the maybeToArray function suggested by @hassankhan but @wirtsi answer did work for my case. Thanks !
from guzzle-services.
I close the issue because it seems to be solved. Please reopen the issue if you have any further questions or the the issue is not solved in your opinion.
from guzzle-services.
Related Issues (20)
- Recommended test setup? HOT 1
- Unable to POST multipart parameters HOT 1
- Is there a way to put other models definition for list items ? HOT 1
- Raw request body data HOT 3
- What am i doing wrong ? HOT 3
- Please document how to use middleware with GuzzleClient HOT 1
- Better responseModel/responseClass feature. HOT 2
- Create request without root key HOT 1
- Support for Multiple `type` Options within Response Models
- Tests Fail with guzzlehttp/psr7 >= 1.6.0 HOT 1
- Feature Request - Ability to Bind Parameter Filters to Specific Request Stages
- What branch is under active development? HOT 2
- Feature Request: Ability to Specify "process: false" at Operation Level
- State of the project HOT 8
- guzzlehttp/guzzle dosn't work after update php to php 8 HOT 2
- Not possible to install on PHP <=7.3 HOT 2
- Why headers are not being passed ?
- Ran into composer issue because package does not auto update. HOT 5
- Extending a parameter that extends another parameter doesn't work as expected
- Add default property into response model HOT 1
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 guzzle-services.