Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to document model attributes with description, examples, etc. #453

Open
sNok3 opened this issue Jul 14, 2024 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@sNok3
Copy link

sNok3 commented Jul 14, 2024

As the title suggests, when generating the docs for a controller which has model binding, the schema for the model will result in just the fields that the model has, without the annotations it has.

@romalytvynenko
Copy link
Member

@sNok3 please share the example of your code and resulting docs. Also would be great to understand what your expected

@sNok3
Copy link
Author

sNok3 commented Jul 14, 2024

image
class Driver extends Model
{
    use HasFactory;
    use HasStatuses;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        /**
         * The internal ID of the associated route
         *
         * @var int
         *
         * @example 1
         */
        'route_id',
        /**
         * The identifier of the activity
         *
         * @example 3d4b6f0e-2b0b-4b0b-8b4b-0b2b4b0b2b4b
         */
        'identifier'
   ];

So as you can see, I have annotations for both fields here, but under the schemas, there are is no information about the model.
image

@romalytvynenko
Copy link
Member

@sNok3 ooh, gotcha. So basically you want to annotate the model fields with descriptions and examples?

Currently this is not supported.

You can use API resources and there you can add the descriptions.

However, I'll keep this issue open to add this possibility in future.

@sNok3
Copy link
Author

sNok3 commented Jul 15, 2024

Yeah, that is exactly what I needed. However, using API resources in the controller method isn't really my way to go for now since I have a big codebase.

However, I'll gladly wait for this to get implemented!

@romalytvynenko romalytvynenko changed the title Controller methods with models as signature not being parsed Add a way to document model attributes with description, examples, etc. Oct 14, 2024
@romalytvynenko romalytvynenko added the enhancement New feature or request label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants