scribe icon indicating copy to clipboard operation
scribe copied to clipboard

Annotation example for boolean values doesn't work correctly

Open BnitoBzh opened this issue 10 months ago • 3 comments

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

BnitoBzh avatar Apr 08 '24 10:04 BnitoBzh

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

mikeah2011 avatar Apr 16 '24 11:04 mikeah2011

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 }

BnitoBzh avatar Apr 16 '24 12:04 BnitoBzh

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

mikeah2011 avatar May 01 '24 09:05 mikeah2011