woohoolabs / yin Goto Github PK
View Code? Open in Web Editor NEWThe efficient and elegant JSON:API 1.1 server library for PHP
License: MIT License
The efficient and elegant JSON:API 1.1 server library for PHP
License: MIT License
I'm running some schema-validation on the output from yin and stumble upon a small issue. It looks like yin is creating the JSON API Object with the key "jsonApi", but the doc always write it in all lowercase.
https://github.com/woohoolabs/yin/blob/master/src/JsonApi/Document/AbstractDocument.php#L78
Something with the new validation seems to have been broken my last PR. I'm looking into it, i just wanted to flag for it here (i read that you were planning to do a release).
Hi,
I want to create a symfony
4
based hateos api that follow jsonapi specs
I can find to valuable implementations :
Those implementations are very similar. On documentation, I can see a link for https://repo.packagist.org/packages/qpautrat/woohoolabs-yin-bundle.
@qpautrat @paknahad Your implementations are very similar.
Is there a way to combine efforts made ?
Regards,
Hi there,
As JSON API specification says
If a relationship is provided in the relationships member of the resource object, its value MUST be a relationship object with a data member.
Correct me if i'm wrong, but ResourceIdentifier does not care about this data
key.
And as we pass complete array in Request it results as null
.
You can try it with this simple example from JSON API documentation:
{
"data": {
"type": "photos",
"attributes": {
"title": "Ember Hamster",
"src": "http://example.com/images/productivity.png"
},
"relationships": {
"photographer": {
"data": { "type": "people", "id": "9" }
}
}
}
}
I just had a look at this commit:
c2ace26#diff-8b9b082f8f14fc68d1683252b988283eR486
Won't that cause an issue when you send null as the value? Like in this case: http://jsonapi.org/format/#crud-updating-to-one-relationships
PATCH /articles/1/relationships/author HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": null
}
Would perhaps be better to use the array_key_exists
method.
According to the specification issuing a PATCH
request which includes a relationship with a {"data":null}
body should clear the relationship, but in HydratorTrait->hydrateRelationships()
this is found:
if (empty($data["relationships"])) {
return $domainObject;
}
which results in the relationship hydrator never being called, is that intentional?
Of course one can override hydrateRelationships()
, but shouldn't the defaults conform to the standards?
Hi @kocsismate,
I have some nullable
fields in my database, then the value of $attribute
is null in
Is this legitimate to encapse this with a is_null
or any check that could avoid Function name must be a string
Regards,
Hi fellows,
I need your POV on this one.
Correct me if i'm wrong but I should be able to set an attribute to my domain object to null if want to.
But as we can see there hydration will be forgotten.
Thereby I'm not able to delete my field description for example.
Thx.
When using cross relations between 2 resources the current design pattern used by the yin resource transformers has the issue of circular dependencies. I think it is necessary to cross relate objects. For example:
I solved this in my case outside of the lib with injecting just a container into the transformers which can require the transformers on demand. But in my opinion this should be solved by the lib itself.
The neomerx lib solves this by mapping the transformers "hard" with the models.. but i liked your modular "loose" approach here.. so maybe a factory patter where one needs to register all transformers and a factory where you can get them whenever you need them could solve the problem.
Hi,
first thank you for the great library! I use it in my project with Zend Expressive and it helped me a lot to implement JSONAPI.
I use the PageBasedPaginationProviderTrait to generate pagination links and I found out it generates Prev and Next links wrong.
The Prev link is null on the last page and the Next link is null on the page before the last page.
The problem is here and here.
I believe that || $this->getPage() >= $this->getLastPage()
should be removed from line 66 and $this->getPage() + 1 >= $this->getLastPage()
should become $this->getPage() >= $this->getLastPage()
on line 79.
Please let me know if this is correct and if I should make a PR to fix it. Thanks!
I'm trying to run the example:
?example=book-rel&id=1&rel=authors
However I'm encountering a fatal:
PHP Catchable fatal error: Argument 1 passed to WoohooLabs\\Yin\\Examples\\Book\\JsonApi\\Resource\\PublisherResourceTransformer::__construct() must be an instance of WoohooLabs\\Yin\\Examples\\Book\\JsonApi\\Resource\\RepresentativeResourceTransformer, none given, called in [...]/yin/examples/Book/Action/GetBookRelationshipsAction.php on line 36 and defined in [...]/yin/examples/Book/JsonApi/Resource/PublisherResourceTransformer.php on line 17
Is there a reason why the methods in AbstractResourceTransformer are private? It causes some problems overriding them, for example you can't override transformAttributesObject() because it is being called elsewhere in the same scope and you need to override those private methods as well.
For the record, what I want to do is extend the class and have this:
public function getAttributes($domainObject) { $ret = []; foreach ($domainObject->attributes as $k=>$v) { if ($k!=$domainObject->primaryKey()) { $ret[$k] = function(CActiveRecord $domainObject, $attr) { return $domainObject->{$attr}; }; } } return $ret; }
I actually believe the fingerprint for the closure there could include the attribute name by default, but that's something you might have considered and rejected already so...
As found by @emil-nasso in #20 when visiting the following example url: ?path=/users/2/relationships/contacts
, the data
member doesn't show up:
{
"links": {
"related": "/?path=/users/2/contacts",
"self": "/?path=/users/2/relationships/contacts"
}
}
However, when including the relationship in question: ?path=/users/1/relationships/contacts&include=contacts
it will be visible:
{
"links": {
"related": "/?path=/users/1/contacts",
"self": "/?path=/users/1/relationships/contacts"
},
"data": [
{
"type": "contact",
"id": "100"
},
{
"type": "contact",
"id": "101"
},
{
"type": "contact",
"id": "102"
}
],
"included": [
{
"type": "contact",
"id": "100",
"links": {
"self": "/?path=/contacts/100"
},
"attributes": {
"phone": "+123456789"
}
},
{
"type": "contact",
"id": "101",
"links": {
"self": "/?path=/contacts/101"
},
"attributes": {
"email": "[email protected]"
}
},
{
"type": "contact",
"id": "102",
"links": {
"self": "/?path=/contacts/102"
},
"attributes": {
"email": "[email protected]"
}
}
]
}
Hi!
Exceptions in namespace WoohooLabs\Yin\JsonApi\Exception
don't have correct codes, they all use default code 0, without the possibility of overriding. This makes it harder to handle these errors. For example, FullReplacementProhibited
should have code 403.
Libraries like jsonapi bundle, that is commonly used with yours, depend on the code to format errors correctly, so it would be nice to have this fixed.
I could make a PR containing the necessary changes if you agree.
If you need to fetch a relationship from a request, you would normally do it like this:
$resource = $jsonApi->getRequest()->getResourceToOneRelationship('spaceship');
This returns a ToOneRelationShip
-object, if the relationship is found, or null
if it is not.
The getResourceToOneRelationship
method in the Request
class looks like this
public function getResourceToOneRelationship($relationship)
{
$data = $this->getResource();
if (isset($data["relationships"][$relationship]["data"]) === false) {
return null;
}
return new ToOneRelationship(ResourceIdentifier::fromArray($data["relationships"][$relationship]["data"]));
}
The last line calls the fromArray
method. The problem is that the fromArray
method does this check:
if (isset($array["type"]) === false || isset($array["id"]) === false) {
return null;
}
So an invalid relationship returns null, but the ToOneRelationship
object gets created anyway. I think it would be clearer if getResourceToOneRelationship
returned null in this case.
To catch the case where the input is malformed, you would have to write code like this with the current code:
$resource = $jsonApi->getRequest()->getResourceToOneRelationship('spaceship');
if (isset($resource)) {
$resourceIdentifier = $resource->getResourceIdentifier();
if ( isset($resourceIdentifier) ) {
//get the id from the resourceIdentifier
}
}
If you don't, you will very likely get an Fatal Error in php.
I would propose that getResourceToOneRelationship
was changed to make sure that ResourceIdentifier:fromArray
considers the data valid, something like this:
public function getResourceToOneRelationship($relationship)
{
$data = $this->getResource();
if (isset($data["relationships"][$relationship]["data"]) === false) {
return null;
}
$resourceIdentifier = ResourceIdentifier::fromArray($data["relationships"][$relationship]["data"]);
if (isset($resourceIdentifier) === false) {
return null;
}
return new ToOneRelationship($resourceIdentifier);
}
With this in place, getResourceToOneRelationship
would return null if the relationship didn't exist, or one of the fields type
or id
was missing.
The getResourceToManyRelationship
would need to be fixed too. I'm not 100% sure on how though. Skip non valid relationships? Return null from the method if one of the identifiers are invalid? Rise some kind of exception? Exceptions could perhaps be used in the getResourceToOneRelationship
case too? Some kind of malformed input exception.
I didn't consider this fully thought through, so i didn't create a PR. What do you think about all this?
Hi @kocsismate,
I can see that we can GET
compound document
https://jsonapi.org/format/upcoming/#document-compound-documents
Can this also be done for creation at the moment ?
Regards,
Hi @kocsismate,
jsonapi specs define the mime type application/vnd.api+json
.
It could be interesting to force consumer to use this mime type, I mean return an HTTP 406
if not.
It let the developer use an other response formalism, for example msgpack ...
What do you think ?
Regards,
The Hydrator ignores attribute if they are not present in the request, the callable is never call.
This is annoying if an attribute is required for example.
I think it should be great to execute all the callable and let the developer decide what it should do, ignore the attribute, set it to null, throw an exception, etc.
I made a commit on my repo lunika@d695581
This is yet again a BC break. An example how ti use it :
protected function getAttributeHydrator($user)
{
return [
'firstname' => function ($user, $attributeValue, $data, $attribute, $isMissing) {
if (true === $isMissing) {
throw new MissingMandatoryAttributeException($attribute);
}
$user['firstname'] = $attributeValue;
return $user;
},
'lastname' => function ($user, $attributeValue, $data, $attribute, $isMissing) {
if (false === $isMissing) {
$user['lastname'] = $attributeValue;
}
return $user;
}
];
}
Hello I have finally integrated Yin into laravel 5.6 with dingo API But stuck here.
Below is my code.
public function show()
{
// Find the current route
$exceptionFactory = new DefaultExceptionFactory();
$deserializer = new JsonDeserializer();
$request = new Request(ServerRequestFactory::fromGlobals(), $exceptionFactory, $deserializer);
// Invoking the current action
$jsonApi = new JsonApi($request, new Response(), $exceptionFactory);
$id = $jsonApi->getRequest()->getAttribute("id");
////country
$country = CountryRepository::getCountry($id);
// Instantiating a book document
$document = new CountryDocument(
new CountryResourceTransformer()
);
// Responding with "200 Ok" status code along with the book document
return $jsonApi->respond()->ok($document, $country);
}
$id = $jsonApi->getRequest()->getAttribute("id");
returns null
my url is of the form http://api.example.com/countries/281615
Are mine implementing this the right way or do i have to use laravel/Dingo Request class Dingo\Api\Http\Request
my route
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
$api->get('countries/{country}', 'App\Api\Controllers\CountryController@show');
}
Works fine if manually set the id
for instance on my user class
$user = UserRepository::getUser(1233);
// Instantiating a book document
$document = new UserDocument(
new UserResourceTransformer(
new CountryResourceTransformer()
)
);
// Responding with "200 Ok" status code along with the book document
return $jsonApi->respond()->ok($document, $user);
using the request url
http://api.example.com/users/11122?include=country&limit=1
I get the response
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "/?path=/user/1233"
},
"data": {
"type": "users",
"id": "1233",
"links": {
"self": "/?path=/users/1233"
},
"attributes": {
"title": "Prof.",
"firstname": "Theo",
"lastname": "Parisian",
"othernames": "Sr.",
"email": "[email protected]",
},
"relationships": {
"country": {
"links": {
"self": "/?path=/users/1233/relationships/country"
},
"data": {
"type": "countries",
"id": "560515"
}
}
}
},
"included": [
{
"type": "countries",
"id": "560515",
"links": {
"self": "/?path=/countries/560515"
},
"attributes": {
"id": 560515,
"long_name": "Armenia",
"short_name": "Sudan",
}
}
]
}
Thanks just need some guidance to complete this.
I'm unsure if this is the intended behavior or not but I was a bit surprised to discover that relationships returned by the transform's getRelationships()
method are still being evaluated even though the relationship name is not present in the include
query parameter nor in the array returned from the transform's getDefaultRelationships()
.
I did a bit of digging and found that when a relationship is being transformed there's a check here that calls both isIncludedField()
and isIncludedRelationship()
to figure out if the relationship should be transformed or not.
However, isIncludedField()
returns true
since the default behavior for fields is to be included if no fields are present in the fields
query parameter, causing the the check to fail and transform to continue.
My assumption would be that if my transformer has two relationships defined in getRelationships()
and only one of them in getDefaultRelationships()
, both relationships should not be evaluated.
If you are a native or fluent English-speaker, please proofread the read me and let's make it more helpful and easy-to-read.
Hi,
I noticed, that in my JSONAPI response the included resources are sorted by id, instead by their original order.
After looking in the code I found out that this line sorts them by id.
I have a question, why is this behavior implemented? In my case I would like to have them sorted in the same way, in which they come from the DB and like they are sorted in the relationships data array. Am I missing something?
Thanks in advance!
Hi,
this is basically an improvement.
I think it would be really cool if the sorting and filter params would automatically be included in the links of the pagination. Basically a pagination is useless if those parameters are not included. Because those values are already available inside the lib, it should be possible. For sure one can solve this in the environment, but it would be a nice improvement of your lib.
I'm using a PSR extension for my PSR interfaces (https://github.com/jbboehr/php-psr) due to the requirements of the PSR package from packagist that one is used.
Could you remove that package as a requirement from the composer.json and let the user decide where to get the interface from?
From my tests I'm getting wrong results here: https://github.com/woohoolabs/yin/blob/master/src/JsonApi/Schema/Pagination/OffsetBasedPaginationLinkProviderTrait.php#L35
In case of 5 total items and limit 100, it will return a negative offset.
In case of 5 total items, offset = 0, limit = 1, it will return offset 3, limit 1, therefore missing the last item.
With 5 total items, offset 4, limit 1, I get no prev link (should be offset 3, limit 1).
I'll try to check it out later on.
Hi!
Does this library use semantic versioning?
If semver is used it would be good if the Readme mention it.
Thanks!
If I want to include a sub-level but skip the intermediary level, it doesn't seem to work.
However I want to preface this with two things:
What I want to do in the following example is to include comments.authors, but not comments. I'm presuming (and here where I could be wrong, so feel free to correct me), but I'm guessing that the right way to do this, according to the spec is simply:
include=comments.authors
However with yin, it seems that I get back both the comments and the authors, instead of just the authors.
How can i integrate woohoolabs/yin with laravel?
Hi,
It looks like $defaultOffset and $defaultLimit is sent in the wrong order here
...($this->getPagination(), $defaultLimit, $defaultOffset);
should be
...($this->getPagination(), $defaultOffset, $defaultLimit);
Test coverage could be improved for some key classes. See the "Test coverage" column here:
https://scrutinizer-ci.com/g/woohoolabs/yin/code-structure/master?elementType=class&orderField=test_coverage&order=asc&changesExpanded=0
Would it be possible to change the return type of respond
to an interface instead? I would like to create a LaravelResponder
that would put the results through a psr7 response bridge first. If you agree I will make a merge request with the code changes needed.
public function respond(): Responder
{
return new Responder($this->request, $this->response, $this->exceptionFactory, $this->serializer);
}
Source from JsonApi: https://github.com/woohoolabs/yin/blob/master/src/JsonApi/JsonApi.php#L83-L86
Hi,
I use this library for the last 2 weeks, it helps me a lot and I would like to discuss with you about some choice you made and understand why.
First of all, why did you choose to create the Responder
in the JsonApi
class ? it makes hard to create our own responder because it is not possible to use it with the original JsonApi
class. Doing this, we have 2 choices :
JsonApi
class and change its behaviourJsonApi
class is just a factory which instanciate a new Responder
injecting a Request
, a Response
, an ExceptionFactory
and a Serializer
.Secondly, why did you choose to couple the Document
witht the serializer
? AFAIK the serializer
is only here to hydrate the Response
, it doesn't transform the Document
in a JsonApi content. It should be great to remove the response in the Document transformation process, I think it's more the Responder responsability to do this. The Responder receive a Document, transform it and then hydrate the response and return it. Just like you did with the Hydrator.
I would be happy to discuss about that and if you want I can help by providing a PoC, contribute to the library, etc.
Hello,
Currently the ResourceNotFound exception bears a 400 status.
I believe it would make more sense to make it a 404.
Or maybe there's a specific reason behind this?
Cheers
Do you have any examples of how to do a multi-level includes?
For example include=comments,comments.authors? (and have it return the right things)
The problem we're seeing is when you try to do multi-level documents it seems to break on validateRelationships -
e.g.
$article = new ArticleDocument(new ArticleResourceTransformer(new CommentResourceTransformer(new AuthorResourceTransformer())));
When CommentResourceTransformer defines a getRelationships($comment) of type "author", it seems to also get validated looking for "comments" in this case and then throws an exception out of "validateRelationships".
I followed the instructions on how to install yin. However, I can't run examples as the instruction is lacking information on how to do that. It'w written that I should run composer install inside yin. OK, did it, it created another vendor folder inside yin and yin was in another vendor folder already as I used composer to install yin for my project. Installing yin using composer doesn't install the folder examples, only src. And inside installed yin folder, running composer install installs a lot of stuff but not the examples folder. Please fix that. I want to use a library for JSON API standard that has validation and everything implemented, however yin and yang seem to be overly complicated as there's no easy tutorial that covers all the cases of CRUD unless it's the folder examples that I can't get to work.
Hello,
Starting a project with current 2.0.2, I'm facing an issue when trying to send POST requests.
Basically the retrieved body ends up being empty, which causes fatal errors.
I've identified the issue to be coming from WoohooLabs\Yin\JsonApi\Request\Request::getParsedBody
, I'll post a PR shortly.
In the json response format used by the current version of yin, i am running into problems that i think is caused by not following the json api specification.
The problem is in the relationships data. Lets take a look at this example:
"data": {
"type": "stuffs",
"id": "st1234",
"links": {
"self": "/stuffs/st1234"
},
"attributes": {
"name": "some stuff",
},
"relationships": {
"account": [],
}
}
In this case, the account-relationsship is not included, and is empty, as can be seen here (or above):
"account": [],
When including the data by adding a include query parameter with the value account, you get this:
"account": {
"data": {
"type": "accounts",
"id": "lb1959846"
}
},
The behaviour that is causing the issues is when the relationship is empty, when there is no data for the relationship. I that case, this will be returned by yin:
"account": [],
This looks identical to what you get when you don't include the relationship at all. Therefor, it is impossible for a client to judge if the relationship has been empty, or if it has simply not been included.
In my case, my client warns the user if they are trying to use data from a relationship that has not been loaded. This make it impossible to know if the object has a relationship with an account, or if it's empty simply because the user choose not to include it.
This is in the specification here:
http://jsonapi.org/format/#fetching-relationships-responses-200
There are examples for both a to-one relationship and a to-many relationship.
If the relationship is included but empty, the data of the response should be like this for a to-one:
"account": {
"data": null
}
and like this for a to-many:
"account": {
"data": []
}
With this, a client would see that the data field is in the response and know that the relationship has been included. If the data is null or an empty array, it just means that the relationship is empty.
I have a working patch for this. I will try to create a pull-request out of it. It needs more sets of eyes.
Hello.
When you POST or PATCH "id" with integer value (for example {"id": 23}) the library generates system exception because of new stricts (strict_types=1) in file \WoohooLabs\Yin\JsonApi\Schema\ResourceIdentifier line 38.
Old version worked with integers because of autocasting in php. I think new version "must" generate "4XX Bad Request, id must be a string" (jsonapi 1.0 standard) or in fast way just to cast value to string, like:
line 38: $resourceIdentifier->setId((string)$array["id"]);
Anyway it's not cool to get 500 when the mistake is in client's requests.
Thanks for your work and library!
It seems you have examples on how to do:
/books/{id}
and
/books/{id}/relationships/authors
But not:
/books/{id}/authors
Unless I'm missing something? Do you natively support this type of call?
Hi,
I started implementing yin into my project and thought lets start with the "simple", but I don't seem to be able to figure out how to implement it. It's mainly the (uncommented) abstract getResource()
-method that's causing the problem.
I haven't tried the AbstractSingleDocument yet, but I am sure that's going to be easy to use (because of the great readme and examples ๐ ).
So my question (request) is if you could provide use with an example of how to use AbstractSimpleResourceDocument.
Thanks in advance!
Hi,
I cannot install the package via composer
composer require woohoolabs/yin
Here is the error
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for woohoolabs/yin ^0.10.8 -> satisfiable by woohoolabs/yin[0.10.8].
- woohoolabs/yin 0.10.8 requires psr/http-message-implementation ^1.0.0 -> no matching package found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
During api testing with Codeception I tried to test multiple routes in same test using @DataProvider
. If I specified 1 route, for example:
/**
* @param FunctionalTester $
* @param Example $example
* @dataProvider getRoutes
*/
public function testSomeRoute(FunctionalTester $I, Example $example): void
{
$I->expect('Data is not empty');
$I->sendGET($example['url']);
$data = $I->grabDataFromResponseByJsonPath('$.data')[0];
$I->assertNotEmpty($data);
}
protected function getRoutes(): array
{
return [
['url' => '/some/route'],
];
}
test will work as expected.
After adding 2 or more routes in data provider, for example:
protected function getRoutes(): array
{
return [
['url' => '/some/route'],
['url' => '/some/other/route'],
['url' => '/example/route'],
];
}
second and third route test will fail because invalid json was returned.
After some debugging I found out that same php://temp
stream is being used for writing response of every route. Response of the second route will be written over response of the first route and if the second response is shorter than the first, part of the first response will still be returned and fail the test because of invalid format.
Back to the articles, comments, authors example:
What I'd like to do, for example, is to retrieve either all the body of comments on an article (but no information/attributes for the article), or all the first-names of authors on an article (again returning no attributes for the article).
According to this discussion:
http://discuss.jsonapi.org/t/clarification-on-the-sparse-fieldset-response/221/2
It seems that the proper way to do this is something like this:
GET /articles/1?include=comments&fields[articles]=&fields[comments]=body
It should return something like this (as copied/interpreted form the discussion linked above):
{
"data": {
"type": "articles",
"id": "1",
},
"included": [{
"type": "comments",
"id": "1",
"attributes": { "body": "yadayada"},
}]
}
However with yin, it seems it's not removing the articles attributes, relationships etc but returning them...
It's been determined this was due to user error. Yin does seem to properly null out attributes (cool!). There's a small other issue which I've highlighted below in a new comment (updating the title of this issue to reflect it)
Hello Woohoolabs !
How are you ?
How do you think about instead hard coded json_encode()
using a SerializerInterface
which could be injected in Document
?
Through this we could be able to inject any Serializer (i'm thinking about JMSSerializer right now) and use it.
Thoughts ?
It should be great to configure a little bit how the json_encode
method is used in the Serializer. Configure all the options and the depth.
You can maybe add this in your v2 roadmap ? :-)
I'm trying to describe a relationship only by the links
for which can be used to fetch the actual data of the related resource.
There are two resources A and B, where A has many Bs. When fetching A the entries of B shouldn't be included.
Performing the following request
GET /api/A/1234 HTTP/1.1
Host: test.dev
Accept: application/json
responds with
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "/api/A/1234"
},
"data": {
"type": "A",
"id": "1234",
"links": {
"self": "/api/A/1234"
},
"attributes": {
"name": "Resource 1"
},
"relationships": {
"B": {
"links": {
"self": "/api/A/1234/relationships/B",
"related": "/api/A/1234/B"
},
"data": []
}
}
}
}
where I'm trying to get a response without the data.relationships.B.data
property (the empty array).
The relationship is described in the transformer for A by:
ToManyRelationship::create()
->setLinks(
Links::createWithoutBaseUri([
'self' => new Link('/api/A/' . $this->getId($a) . '/relationships/B'),
'related' => new Link('/api/A/' . $this->getId($a) . '/B'),
])
)
->omitWhenNotIncluded()
The documentation states that a relationship must contain at least one of the three properties: links
, data
, or meta
. (it's valid without the data
property).
It seems like commit 1aef043 forces the data
property to be present. It was implemented to resolve #22. The commit basically assigns a variable $x = $y
, and then later compares the two $x === $y
.
I'm not sure about what the Transformation::$fetchedRelationship
variable should express, but comparing issue #22 with the analogy of my case, my best guess is that it should represent resource A, thereby ensuring that the data
property of A is present at the outer scope.
Hi @kocsismate,
Database id
are considered as string, for example in hasIncludedResource
.
Should not id
be considered as int
?
Regards,
Following line in "protected function isValidMediaTypeHeader" in src/JsonApi/Request/Request.php
return strpos($header, "application/vnd.api+json") === false || $header === "application/vnd.api+json";
returns true even if the header is wrong. It should be:
return strpos($header, "application/vnd.api+json") !== false || $header === "application/vnd.api+json";
And i think the second statement is not necessary.
return strpos($header, "application/vnd.api+json") !== false;
should be enough.
In the WoohooLabs\Yin\JsonApi\Schema\Data\CollectionData class a ksort is performed on the $ids.
I want to order the results the way I setup my SQL (using an 'order by') but this ksort is causing unexpected behaviour. Am I missing something?
Hi, when i try to install your package using composer i receive the following error message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- woohoolabs/yin 1.0.2 requires psr/http-message-implementation ^1.0.0 -> no matching package found.
- woohoolabs/yin 1.0.1 requires psr/http-message-implementation ^1.0.0 -> no matching package found.
- woohoolabs/yin 1.0.0 requires psr/http-message-implementation ^1.0.0 -> no matching package found.
- Installation request for woohoolabs/yin ~1.0 -> satisfiable by woohoolabs/yin[1.0.0, 1.0.1, 1.0.2].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
A package psr/http-message-implementation does not exists, so i think it should be psr/http-message
, correct?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.