Mezatsong / laravel-swagger-docs

MIT License
20 stars 8 forks source link

TypeError Mezatsong\SwaggerDocs\Parameters\BodyParametersGenerator::addToProperties(): Argument #1 ($properties) must be of type array, null given #5

Closed Mezatsong closed 1 year ago

Mezatsong commented 1 year ago

I have an issue when I put an array in validation, specialy when the name of the rule end with *

image

The FormRequest:

public function rules()
    {   
        return [
            'label' => 'required|string',
            'type' => 'required|string|in:' . implode(',', TestType::allCaseInStr()),
            'simulateur_id' => 'required|exists:simulateurs,id',
            'time' => 'required|numeric|min:1', // en seconde
            'lang' => 'required|string|size:2',
            'sub_title' => 'nullable|string',

            'questions' => 'required|array|min:1',
            'questions.*.title' => 'required|string',
            'questions.*.images' => 'present|array',
            'questions.*.images.*' => 'required|base64image',
            'questions.*.content' => 'nullable|string',
            'questions.*.explanation' => 'nullable|string',
            'questions.*.explanation_images' => 'present|array',
            'questions.*.explanation_images.*' => 'required|base64image',
            'questions.*.max_responses' => 'required|numeric|min:0',

            'questions.*.answers' => 'required|array|min:1',
            'questions.*.answers.*' => 'required',
            'questions.*.answers.*.content' => 'required|string',

            'questions.*.answers.*.is_correct' => 'required|boolean',
            'questions.*.answers.*.images' => 'present|array',
            'questions.*.answers.*.images.*' => 'required|base64image',
        ];

The Error:


   TypeError 

  Mezatsong\SwaggerDocs\Parameters\BodyParametersGenerator::addToProperties(): Argument #1 ($properties) must be of type array, null given, called in C:\User
s\B_Soft\Projects\Free-lance\adaa\codes\api.adaacertif.com\vendor\mezatsong\laravel-swagger-docs\src\Parameters\BodyParametersGenerator.php on line 122      

     92▕         if (\count($nameTokens) === 0) {
     93▕             return;
     94▕         }
     95▕

  1   C:\Users\B_Soft\Projects\Free-lance\adaa\codes\api.adaacertif.com\vendor\mezatsong\laravel-swagger-docs\src\Parameters\BodyParametersGenerator.php:122 
      Mezatsong\SwaggerDocs\Parameters\BodyParametersGenerator::addToProperties()

  2   C:\Users\B_Soft\Projects\Free-lance\adaa\codes\api.adaacertif.com\vendor\mezatsong\laravel-swagger-docs\src\Parameters\BodyParametersGenerator.php:120 
      Mezatsong\SwaggerDocs\Parameters\BodyParametersGenerator::addToProperties()
evolvoltd commented 1 year ago

Hi, quick fixes-patches for this issue and issue 6 https://github.com/Mezatsong/laravel-swagger-docs/pull/8

Mezatsong commented 1 year ago

Hi, quick fixes-patches for this issue and issue 6 #8

Thank you