Comments (4)
Awesome, thank you so much! Fix is on the way. This is exactly the problem.
Will ping you here once done.
from scramble.
Hey @antonhedling
Just released 0.3.0
, please update: https://github.com/dedoc/scramble/releases/tag/v0.3.0
The issue should be fixed.
Thanks for your time and reporting the issue.
from scramble.
Hey @antonhedling!
Thanks for reporting!
If you found an endpoint causing this, can you please send me more code?
- Full resource class' source (both
SchoolResource
and the resource which containsschools
) - Full controller class (or, at least, a method code)
This should be a good point for me to start.
Thanks!
from scramble.
Okay, I did just now find out the line that is causing this, so it looks like this isn't necessarily connected to $this->whenLoaded()
.
It's when two resources cross-reference one another:
AreaResource.php
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class AreaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'subareas' => $this->subareas,
'schools' => SchoolResource::collection($this->whenLoaded('schools')),
];
}
}
SchoolResource.php
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class SchoolResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'area' => new AreaResource($this->area),
];
}
}
If I remove the AreaResource there, it works again.
I mean sure, you can argue that resources shouldn't look like this. But it would be great if we could prevent whatever infinite loop is caused here.
from scramble.
Related Issues (20)
- PHP8.2 issues
- Installation issue HOT 1
- Ressource Array-KeyConstants are not validated HOT 1
- Have an error Target [\Illuminate\Database\Eloquent\Model] is not instantiable. HOT 3
- Multiple files in array (Content-Type: multipart/form-data)
- OpenAPI Links parameter support
- Add @example for response types HOT 8
- "No response" returns invalid openapi spec HOT 2
- Deprecated methods error
- Error when grouping routes by tags: Undefined array key 0
- MethodReflector on buffer method HOT 2
- All responses values return as string HOT 6
- When extending Resources and using parent::toArray, Docs are returning string. HOT 1
- auth:sanctum is not detected or documented? HOT 7
- Error when analyzing route with non-existing model
- Cannot generate request documentation: Call to undefined method App\Models\User::setMethod()
- Attempt to read property "methods" on null HOT 11
- php 8.2 and laravel 10. php-parser version 5 not compatible HOT 8
- Additional collection’s data: Not documenting HOT 1
- How could we handle passport auth? HOT 3
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 scramble.