knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.58k stars 280 forks source link

Annotation example for boolean values doesn't work correctly #836

Open BnitoBzh opened 2 months ago

BnitoBzh commented 2 months ago

Scribe version

4.35.0

PHP version

8.3.3

Framework

Laravel

Framework version

10.43.0

Scribe config

type => "laravel"
theme => "elements"
static.output_path => "public/api/docs"
laravel.docs_url => "/api/docs"
auth.enabled => true
auth.default => true
auth.name => "apiKey"

What happened?

Attribute annontations do not render boolean examples correctly.

#[BodyParam('newsletter', 'boolean', description: 'Opt-in status for newsletter', required: true, example: true)] #[BodyParam('newsletter', 'boolean', description: 'Opt-in status for newsletter', required: true, example: false)]

With true or false value as example, there is no example text in the documentation and for falsevalue the curl example is correct, but with the true value, the curl example is set to null

Docs

mikeah2011 commented 2 months ago

#[QueryParam('is_api_user', 'boolean', '聯盟站點是否異業串接', false, 'true', ['true-是', 'false-否'])]

BnitoBzh commented 2 months ago

Sorry @mikeah2011 i am speaking about BodyParam not QueryParam. If the example for a boolean BodyParam is set as string, like your comment 'true', the API json body sample use the type string instead of the type boolean. In my example, the sample will be : { "newsletter": "true" } instead of { "newsletter": true }

mikeah2011 commented 1 month ago

Yes, the string true cannot solve the problem perfectly. I have made a correction, please refer to it.