oligus / jad Goto Github PK
View Code? Open in Web Editor NEWJSON Api to Doctrine
License: MIT License
JSON Api to Doctrine
License: MIT License
When creating a new resource adding relationship generates an error.
{
"data": {
"type": "photos",
"attributes": {
"title": "Ember Hamster",
"src": "http://example.com/images/productivity.png"
},
"relationships": {
"photographer": {
"data": { "type": "people", "id": "9" }
}
}
}
}
{{url}}:8000/api/jad/tracks?filter[tracks.albums][and][title][like]=taste
Above. Why is necessary filter[tracks.albums] instead of filter[albums]? I think everything is about Tracks entity.
[Description of the bug or feature]
Complete removal of tobscure/jsonapi and create similar functionality under Jad/Document.
Pagination and result count specifically does not take into account filtering properties and thus count is off (always counts total number of records).
Remove the singular plural issue, every resource name should be in plural
Crud classes Create
and Update
are non-DRY and all but identical.
In order to get this to work with Symfony 4, the dependencies and if not the code needs to be updated to support the newer versions of symfony/http-foundation and not just 3.2 which it seems to be requesting.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- oligus/jad v1.1.3 requires symfony/http-foundation ^3.2 -> no matching package found.
- oligus/jad v1.1.2 requires symfony/http-foundation ^3.2 -> no matching package found.
- oligus/jad v1.1.1 requires symfony/http-foundation ^3.2 -> no matching package found.
- oligus/jad v1.1.0 requires symfony/http-foundation ^3.2 -> no matching package found.
- Installation request for oligus/jad ^1.1 -> satisfiable by oligus/jad[v1.1.0, v1.1.1, v1.1.2, v1.1.3].
At least that's what I'm pretty sure the issue is.
This
* @JAD\Header(type="work-wrong-type")
should have been:
* @JAD\Header(type="work-classification")
You get the following error:
{"errors":[{"status":"0","title":"Error Exception error","detail":"array_merge(): Argument #2 is not an array"}]}
Update.php has a typo where
ClassHelper::setPropertyValue($entity, $relatedProperty, $reference);
Should have a "$relatedType" as the second argument instead of "$relatedProperty". $relatedType should also be "deKebabifyed" otherwise Jad can't find the Entity.
Hi Oli, kudos for a job well done! I have a question regarding standalone usage.
Let's assume that I have my router that takes Symfony\Component\HttpFoundation\Request and returns Symfony\Component\HttpFoundation\Response. Can you please tell me how can I can achieve something like that:
<?php
use Jad\Jad;
use Jad\Map\AnnotationsMapper;
use Jad\Request\JsonApiRequest;
use Jad\Request\Parameters;
use Jad\Response\JsonApiResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class JsonApiRouter
{
public function __invoke(Request $request): Response
{
$parameters = new Parameters();
$parameters->setArguments($request->query->all());
$mapper = new AnnotationsMapper($this->getEm());
$jsonApiRequest = new JsonApiRequest($request, $parameters);
$jsonApiRequest->setPathPrefix('/json');
$response = new JsonApiResponse($jsonApiRequest, $mapper);
return $response->getRawResponse(); // this is what I miss :)
}
}
Jad as middleware should optionally return response object instead of rendering results.
Add relevant meta information (not specified).
When in pagination, total count, number of pages.
Make CORS settings configurable
Automatically add meta data such as pagination information and counts
When reading from endpoint /api/jad/customers/1 in demo:
"first-name": "Lu\u00eds",
"last-name": "Gon\u00e7alves"
EntitySerializer tries to serialize even if the entity is empty.
In Serializers/EntitySerializer.php:87, fetching the relationship by type may return NULL or empty result set.
I have 3 languages: english, portuguese and spanish.
In "Postman" when I call "/languages" in "preview" seems correct, but when I change to "Pretty" show me a "syntax error". I paste the response in JsonLint and the data seems to be duplicade.
The database:
The "LanguageController":
This is the response:
{"data":[{"id":"1","type":"languages","attributes":{"name":"Portugu\u00eas","alias":"br","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:32","updated-at":"2017-12-20 14:51:32"}},{"id":"2","type":"languages","attributes":{"name":"Espanhol","alias":"es","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:33","updated-at":"2017-12-20 14:51:33"}},{"id":"3","type":"languages","attributes":{"name":"Ingl\u00eas","alias":"en","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:33","updated-at":"2017-12-20 14:51:33"}}],"links":{"self":"http:\/\/localhost\/languages"}}{"data":[{"id":"1","type":"languages","attributes":{"name":"Portugu\u00eas","alias":"br","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:32","updated-at":"2017-12-20 14:51:32"}},{"id":"2","type":"languages","attributes":{"name":"Espanhol","alias":"es","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:33","updated-at":"2017-12-20 14:51:33"}},{"id":"3","type":"languages","attributes":{"name":"Ingl\u00eas","alias":"en","active":true,"deleted-at":null,"created-at":"2017-12-20 14:51:33","updated-at":"2017-12-20 14:51:33"}}],"links":{"self":"http:\/\/localhost\/languages"}}
[Description of the bug or feature]
Warning: array_merge(): Argument #2 is not an array in
/Users/oli/PhpstormProjects/jad/src/Document/Resource.php on line 137
Pick up target entity and add, in this case, "support-rep" to mapping so it can be included. EntitySerializer.php:78 returns null (mapping not found)
/**
* @ORM\ManyToOne(targetEntity="Employees", fetch="EAGER")
* @ORM\JoinColumn(name="SupportRepId", referencedColumnName="EmployeeId")
*/
protected $supportRep;
How to update "many to many" relation correctly?
{
"data": {
"id":2,
"type": "users",
"attributes": {
},
"relationships": {
"groups": {
"data":
[
{ "type": "groups", "id": 1 },
{ "type": "groups", "id": 5 }
]
}
}
}
}
Above its add to pivot table, but how only update data in pivot table?
[Description of the bug or feature]
Possibility to hook in event listeners to JAD before and after operations.
preRender(string $type, $id),
postRender(string $type, $id),
preFlush(string $type, $id),
postFlush(string $type, $id)
[Description of the bug or feature]
When I set the annotation @jad\Attribute(visible=false) the field is still displayed on return.
If you by mistake have the same include twice you get it twice. Should probably throw an error or handle it in some way.
ex: http://app.com/api/jad/1?include=thing-to-include,thing-to-include
api/jad/work-classification?filter[work-classification][classification][like]=Xf renders error:
{"errors":[{"status":"0","title":"Query error","detail":"[Syntax Error] line 0, col 13: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_FROM, got '-'"}]}
api/jad/work-classification?filter[workClassification][classification][like]=Xf however, works as excepted.
Automatically add links to resources, collections and document
When including entities, Doctrine does not do the join due to lazy loading. This should not be required by JAD. If a entity is included, make Doctrine join in related table despite the entity's fetch option.
Simple fix for the operation of filter parameters with isNull and isNotNull.
Now you can do something like this:
?filters[status][isNull]=status (or empty some string | empty value)
or
?filters[status][isNotNull]=status (or empty some string | empty value)
Multiple includes that do not exist for current resource should render an error array instead of single error.
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.