knuckleswtf / scribe

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

Support specifying `Example: null` in annotations #755

Closed liverocaisson closed 7 months ago

liverocaisson commented 8 months ago

Allow null parameter in the generation of API example specification

@bodyParam col_id integer required ID Example: null 
@bodyParam col_name string name Example: null

Example of use We want to put null value in the database. We want to pass null as ID to create a new ID. //presence of parameter required We want to pass null instead of '' string.

liverocaisson commented 8 months ago

@bodyParam col_name string name Example: null The example above, null is ignored and not written in the specification. It's seems that if we don't put required, the example is ignored.

How to not ignore non-required, intentional null example ?

Can you give me some guidance about the file to modify to allow this logic.

liverocaisson commented 8 months ago

I found why intentional null example are ignored.

I have added a if condition to not ignore null example, if the example is intentionally written as the example below

@bodyParam col_name string name Example: null

src/Extracting/Extractor.php

shalvah commented 7 months ago

Thanks!