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

feat: add required to responseField tag and append the required fields to generateResponseContentSpec for object types #814

Open yannick-softwerft opened 4 months ago

yannick-softwerft commented 4 months ago

Extends the documentation for @responseField tags by adding the required field.

Format before was:

// Format:
// @responseField <name> <type>  <description>

Format after is:

// Format:
// @responseField <name> <type> <"required" (optional)> <description>

If required is set in the documentation it will set the new $required- property (ResponseField Dto) to true. All fields that have the required property set to true will be added to the openapi spec for object types.

shalvah commented 4 months ago

Could you add some tests as well? You don't necessarily need to add new tests, just find some of the tests around @responseField and #[ResponseField] and ensure they generate the correct parameter values. Also add some cases in the OpenAPI spec writer test that handle required/optional.

yannick-softwerft commented 3 months ago

Could you add some tests as well? You don't necessarily need to add new tests, just find some of the tests around @responseField and #[ResponseField] and ensure they generate the correct parameter values. Also add some cases in the OpenAPI spec writer test that handle required/optional.

Yes, I will do that, but I will probably not be able to do it until 15.03.2024.

shalvah commented 3 months ago

Ready for review? It's still marked as draft.