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

Fix sample body with array of object #720

Closed stephane-monnot closed 10 months ago

stephane-monnot commented 10 months ago

Hi,

Fix sample body with an object of array. For example :

    #[BodyParam('fields', 'object[]', 'Form\'s fields', required: false)]
    #[BodyParam('fields[].name', 'string', 'Field\'s name', required: true, example: 'experience')]
    #[BodyParam('fields[].label', 'string', 'Field\'s label', required: true, example: 'Expérience')]
    #[BodyParam('fields[].type', 'string', 'Field\'s type', required: true, example: 'textarea')]
    #[BodyParam('fields[].order', 'number', 'Field\'s order', required: true, example: 1)]

Before

{
    "name": "Experience Form",
    "fields": {
        "name": "experience",
        "label": "Exp\u00e9rience",
        "type": "textarea",
        "order": 1
    }
}

After

{
    "name": "Experience Form",
    "fields": [
        {
            "name": "experience",
            "label": "Exp\u00e9rience",
            "type": "textarea",
            "order": 1
        }
    ]
}
shalvah commented 10 months ago

Cool. Could you rename some of those test methods? get_sample_body() and bodyParams() are too generic names for a test that's designed to test certain specific things (in this case, array fields).

stephane-monnot commented 10 months ago

Thank you for the review. I have renamed the methods.