Comments (5)
That is a great idea, I had this in my TODO list. I'll hopefully get to this soon
from laravel-swagger.
@mtrajano Proof Of Concept with shitty code :D
Problems
- How to get any model with filled data
- Have no idea how to fill any resource with full data
- Have no idea how to correctly extract that structure from resource
- Need deep definition extraction/creation to avoid duplication and creating subresource definitions.
- Controller methods can return collection/single resource or even some custom response that contain resource deeply.
from laravel-swagger.
@sanasol thank you so much for submitting a pr for this. I need to think about this one a little more. I'm usually hesitant to include another annotation unless necessary (less bootstrapping needed to get the correct output), do you think it would be possible to rely on the return typehint of a specific Api Resource and leave the @model
as is which would instruct which model should be passed into the resource? Also would appreciate some tests at least proving that the implementation works. I'm currently working on cleaning up this branch and trying to add as much test coverage as possible in order to do a more stable release. Thanks!
from laravel-swagger.
This is very PoC, so it wont work anywhere except my environment.
I tried replace @model
with resource until found that need both for make it work somehow.
So with clean implementation it should some kind of @resource
+ @model
.
But now I found out that attaching to resource also is bit useless, since response can be actually with any structure incuding some simple array.
So my current thoughts that need some custom response classes with full response structure written in annotation. i.e. empty classes with response structure and data types.
i.e. it will be just php-written swagger structure with autogeneration or something like.
I didnt see any other possible solutions that will generate swagger with reallife responses automatically.
So in my mind now:
Controller method annotation
/**
* @response App\Responses\ResumeResponse
*/
Response class that linked to some "sub responses"
namespace App\Responses;
class ResumeResponse
{
public static function generate()
{
return [
'id' => 'number',
'name' => 'string',
'experience' => [App\Responses\ExperienceResponse::class], // collection
'common_skill' => App\Responses\CommonSkillResponse::class, // single object
];
}
}
so ExperienceResponse
and CommonSkillResponse
have same generate() method inside with some structure.
Actually this is very close to writing full docs manually, but with php syntax.
from laravel-swagger.
I started prototyping a solution for this involving traversing the AST -- mr-feek@8f3bbad
from laravel-swagger.
Related Issues (20)
- Ability to add tags HOT 1
- Ability to add description for parameters HOT 1
- Multipart for file values HOT 1
- mtrajano/laravel-swagger works for Lumen? HOT 1
- Error: "Your requirements could not be resolved to an installable set of packages" HOT 1
- SuccessResponseGenerator is missing methods HOT 3
- Ability to use custom Router provider HOT 1
- Laravel 7 support HOT 10
- missing --filter in 0.7-dev HOT 2
- Command option --filter is broken
- [Proposal] Get additional middlewares defined on controllers HOT 3
- Laravel 8 installation problem HOT 4
- Can't generate when debugger is present
- Auth option for session based internal API
- ReflectionException : Method Modules\Admin\Http\Controllers\CompanyController::destroy() does not exist
- When using --filter the config option basePath it's ignored
- support or update for laravel 8 HOT 1
- PHP 8 deprecation (ReflectionParameter::getClass())
- How to add parameter description and return value description
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 laravel-swagger.