From dee3246bc57b95049440cbc00daa4017fec1cd18 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 2 Jul 2025 15:35:50 +0300 Subject: [PATCH 01/29] refactor: display throwable errors too --- resources/views/error.blade.php | 2 +- src/Services/SwaggerService.php | 6 +- tests/SwaggerServiceTest.php | 6 +- ...rrect_documentation_structure_request.json | 400 ++++++++++++++++++ ...rrect_documentation_structure_request.html | 1 + 5 files changed, 410 insertions(+), 5 deletions(-) create mode 100644 tests/fixtures/SwaggerServiceTest/documentation/tmp_data_incorrect_documentation_structure_request.json create mode 100644 tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php index 0b9291cb..e352a8c9 100644 --- a/resources/views/error.blade.php +++ b/resources/views/error.blade.php @@ -1 +1 @@ -{{ $message }} \ No newline at end of file +### **{{ $message }}** \ No newline at end of file diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index b81eeff3..19b3e476 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -23,7 +23,7 @@ use RonasIT\AutoDoc\Traits\GetDependenciesTrait; use RonasIT\AutoDoc\Validators\SwaggerSpecValidator; use Symfony\Component\HttpFoundation\Response; -use Exception; +use Throwable; /** * @property SwaggerDriverContract $driver @@ -831,7 +831,7 @@ public function getDocFileContent() $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); - } catch (Exception $exception) { + } catch (Throwable $exception) { return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]); } @@ -973,7 +973,7 @@ protected function prepareInfo(?string $view = null, array $viewData = [], array if (!empty($view)) { $info['description'] = view($view, $viewData)->render(); } - + return array_merge($this->config['info'], $info); } diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index bd6bc03d..6e7205d6 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -222,6 +222,10 @@ public static function getConstructorInvalidTmpData(): array 'tmpDoc' => 'documentation/invalid_format__response__invalid_items', 'fixture' => 'invalid_format_response_invalid_items.html', ], + [ + 'tmpDoc' => 'documentation/tmp_data_incorrect_documentation_structure_request', + 'fixture' => 'invalid_format_incorrect_documentation_structure_request.html', + ], ]; } @@ -234,7 +238,7 @@ public function testGetDocFileContentInvalidTmpData( $content = app(SwaggerService::class)->getDocFileContent(); - $this->assertEqualsFixture($fixture, $content['info']['description']); + $this->assertStringContainsString($this->getFixture($fixture), $content['info']['description']); } public function testEmptyContactEmail() diff --git a/tests/fixtures/SwaggerServiceTest/documentation/tmp_data_incorrect_documentation_structure_request.json b/tests/fixtures/SwaggerServiceTest/documentation/tmp_data_incorrect_documentation_structure_request.json new file mode 100644 index 00000000..df9611dd --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/documentation/tmp_data_incorrect_documentation_structure_request.json @@ -0,0 +1,400 @@ +{ + "openapi": "3.1.0", + "servers": [ + { + "url": "https:\/\/localhost" + } + ], + "paths": { + "\/v{version}\/media": { + "post": { + "tags": [ + "v{version}" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "parameters": [ + { + "in": "path", + "name": "version", + "description": "in: 0.1,0.2", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "201": { + "description": "Created", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/postV{version}media201ResponseObject" + }, + "example": { + "id": 20, + "link": "https:\/\/localhost\/v0.2\/media\/20\/content", + "created_at": "2018-11-11T11:11:11.000000Z", + "preview": { + "id": 19, + "link": "https:\/\/localhost\/v0.2\/media\/19\/content", + "created_at": "2018-11-11T11:11:11.000000Z", + "blur_hash": null + }, + "blur_hash": "L00000fQfQfQfQfQfQfQfQfQfQfQ" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/postV{version}media401ResponseObject" + }, + "example": { + "message": "Unauthenticated." + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "requestBody": { + "content": { + "application\/json": { + "schema": { + "$ref": "#\/components\/schemas\/v{version}mediaObject" + } + } + }, + "description": "", + "required": true + }, + "summary": "create media" + } + }, + "\/v{version}\/media\/{id}\/content": { + "get": { + "tags": [ + "v{version}" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "image\/jpeg", + "application\/json" + ], + "parameters": [ + { + "in": "path", + "name": "version", + "description": "in: 0.1,0.2", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "id", + "description": "regexp: [0-9]+", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Operation successfully done", + "content": { + "image\/jpeg": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/getV{version}media{id}content200ResponseObject" + }, + "example": "[]" + } + } + }, + "429": { + "description": "Too Many Requests", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/getV{version}media{id}content429ResponseObject" + }, + "example": { + "message": "Too Many Attempts." + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/getV{version}media{id}content403ResponseObject" + }, + "example": { + "message": "This action is unauthorized." + } + } + } + }, + "404": { + "description": "This entity not found", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/getV{version}media{id}content404ResponseObject" + }, + "example": { + "message": "Media does not exist" + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "summary": "get content" + } + }, + "\/media\/{id}": { + "delete": { + "tags": [ + "media" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "This entity not found", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/deleteMedia{id}404ResponseObject" + }, + "example": { + "message": "Not found." + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "summary": "delete media" + } + }, + "\/media\/bulk": { + "post": { + "tags": [ + "media" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "parameters": [], + "responses": { + "404": { + "description": "This entity not found", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/postMediabulk404ResponseObject" + }, + "example": { + "message": "Not found." + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "requestBody": { + "content": { + "application\/json": { + "schema": { + "$ref": "#\/components\/schemas\/mediabulkObject" + } + } + }, + "description": "", + "required": true + }, + "summary": "bulk create media" + } + }, + "\/media": { + "get": { + "tags": [ + "media" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "parameters": [ + { + "in": "query", + "name": "page", + "description": "integer", + "schema": { + "type": "integer" + } + }, + { + "in": "query", + "name": "per_page", + "description": "integer", + "schema": { + "type": "integer" + } + }, + { + "in": "query", + "name": "all", + "description": "integer", + "schema": { + "type": "integer" + } + }, + { + "in": "query", + "name": "query", + "description": "string", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "order_by", + "description": "string, in:link,name", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "desc", + "description": "boolean", + "schema": { + "type": "boolean" + } + }, + { + "in": "query", + "name": "name", + "description": "string", + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "This entity not found", + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/getMedia404ResponseObject" + }, + "example": { + "message": "Not found." + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "summary": "search media" + }, + "post": { + "tags": [ + "media" + ], + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "parameters": [], + "content": { + "application\/json": { + "schema": { + "type": "object", + "$ref": "#\/components\/schemas\/postMedia404ResponseObject" + }, + "example": { + "message": "Not found." + } + } + } + } + }, + "security": [], + "description": "", + "deprecated": false, + "requestBody": { + "content": { + "application\/json": { + "schema": { + "$ref": "#\/components\/schemas\/mediaObject" + } + } + }, + "description": "", + "required": true + }, + "summary": "create media" + } +}}, "components": {"schemas": {"v{version}mediaObject": {"type": "object", "properties": {"file": {"type": "string", "description": "file, max:5120, mimes:jpg,jpeg,bmp,png,heic"}, "meta": {"type": "object", "description": ""}, "is_public": {"type": "boolean", "description":""}, "type": {"type": "string","description": "in:avatar,cover"}}, "required":["file"], "example": {"file": "[uploaded_file]"}},"postV{version}media201ResponseObject": {"type": "object", "properties": {"id": {"type": "integer"}, "link":{"type": "string"}, "created_at": {"type": "string"}, "preview": {"type": "array", "nullable": true}, "blur_hash": {"type": "string"}}}, "postV{version}media401ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}, "getV{version}media{id}content200ResponseObject": {"type": "object", "properties":[]}, "getV{version}media{id}content429ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}, "getV{version}media{id}content403ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}, "getV{version}media{id}content404ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}, "deleteMedia{id}404ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}, "mediabulkObject": {"type": "object", "properties": {"media": {"type": "object", "description": ""}, "media.*": {"type": "object", "description": ""}, "media.*.file": {"type": "string", "description": "file, max:5120, mimes:jpg,jpeg,bmp,png,heic"}, "media.*.meta":{"type": "object", "description": ""},"media.*.is_public": {"type": "boolean", "description": ""}}, "required":["media", "media.*.file"], "example": {"media":[{"meta":["test1"], "file": "[uploaded_file]"}, {"meta":["test2"], "file": "[uploaded_file]"}]}}, "postMediabulk404ResponseObject": {"type": "object","properties": {"message": {"type": "string"}}}, "getMedia404ResponseObject": {"type": "object","properties": {"message": {"type": "string"}}}, "mediaObject": {"type": "object","properties": {"file": {"type": "string","description": "file, max:5120, mimes:jpg,jpeg,bmp,png,heic"}, "meta": {"type":"object", "description": ""}, "is_public": {"type": "boolean", "description": ""}, "type": {"type": "string", "description": "in:avatar,cover"}}, "required":["file"], "example": {"file": "[uploaded_file]"}},"postMedia404ResponseObject": {"type": "object", "properties": {"message": {"type": "string"}}}}}, "info": {"description": "This is automatically collected documentation", "version": "0.0.0", "title": "Laravel", "termsOfService": "", "contact": {"email": "azabolotnikov@ronasit.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html new file mode 100644 index 00000000..aa91da31 --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -0,0 +1 @@ +Return value must be of type array, null returned \ No newline at end of file From 1c7dfcfeccd0f0ca28ccddb79223b6eaaad22061 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Thu, 3 Jul 2025 17:00:57 +0300 Subject: [PATCH 02/29] refactor: set empty array for not exception errors --- resources/views/error.blade.php | 12 +++++++++++- src/Services/SwaggerService.php | 9 +++++++-- tests/SwaggerServiceTest.php | 2 +- tests/TestCase.php | 2 +- .../invalid_format_array_parameter_no_items.html | 12 +++++++++++- .../invalid_format_array_response_body_no_items.html | 12 +++++++++++- ...nvalid_format_array_response_header_no_items.html | 12 +++++++++++- .../invalid_format_body_and_form_params.html | 12 +++++++++++- .../invalid_format_duplicate_header_params.html | 12 +++++++++++- .../invalid_format_duplicate_operation_id.html | 12 +++++++++++- .../invalid_format_duplicate_path_params.html | 12 +++++++++++- .../invalid_format_duplicate_path_placeholders.html | 12 +++++++++++- .../invalid_format_duplicate_tag.html | 12 +++++++++++- .../invalid_format_file_invalid_consumes.html | 12 +++++++++++- .../invalid_format_file_no_consumes.html | 12 +++++++++++- ...at_incorrect_documentation_structure_request.html | 12 +++++++++++- .../invalid_format_invalid_schema_type.html | 12 +++++++++++- .../invalid_format_invalid_value_parameter_in.html | 12 +++++++++++- .../invalid_format_invalid_value_path.html | 12 +++++++++++- .../invalid_format_invalid_value_status_code.html | 12 +++++++++++- .../invalid_format_missing_external_ref.html | 12 +++++++++++- ...invalid_format_missing_field_definition_type.html | 12 +++++++++++- .../invalid_format_missing_field_header_type.html | 12 +++++++++++- .../invalid_format_missing_field_info_version.html | 12 +++++++++++- .../invalid_format_missing_field_items_type.html | 12 +++++++++++- ...lid_format_missing_field_operation_responses.html | 12 +++++++++++- .../invalid_format_missing_field_parameter_in.html | 12 +++++++++++- .../invalid_format_missing_field_paths.html | 12 +++++++++++- ...id_format_missing_field_response_description.html | 12 +++++++++++- .../invalid_format_missing_field_tag_name.html | 12 +++++++++++- .../invalid_format_missing_local_ref.html | 12 +++++++++++- .../invalid_format_missing_path_parameter.html | 12 +++++++++++- .../invalid_format_missing_ref_file.html | 12 +++++++++++- .../invalid_format_multiple_body_params.html | 12 +++++++++++- .../invalid_format_no_path_params.html | 12 +++++++++++- .../invalid_format_path_param_no_placeholder.html | 12 +++++++++++- .../invalid_format_request_body_invalid_content.html | 12 +++++++++++- .../invalid_format_response_invalid_items.html | 12 +++++++++++- .../invalid_format_security_definition_flow.html | 12 +++++++++++- .../invalid_format_security_definition_in.html | 12 +++++++++++- .../invalid_format_security_definition_type.html | 12 +++++++++++- .../fixtures/SwaggerServiceTest/invalid_version.html | 12 +++++++++++- 42 files changed, 438 insertions(+), 43 deletions(-) diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php index e352a8c9..9e1b884a 100644 --- a/resources/views/error.blade.php +++ b/resources/views/error.blade.php @@ -1 +1,11 @@ -### **{{ $message }}** \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 {{$type}} 🚨🚨 + +--- + +### **Details:** + +{{$message}} + +--- \ No newline at end of file diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 83da0fa0..5a718701 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -24,7 +24,7 @@ use RonasIT\AutoDoc\Validators\SwaggerSpecValidator; use Symfony\Component\HttpFoundation\Response; use Throwable; - +use Exception; /** * @property SwaggerDriverContract $driver */ @@ -832,7 +832,12 @@ public function getDocFileContent() $this->openAPIValidator->validate($documentation); } catch (Throwable $exception) { - return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]); + $message = $exception instanceof Exception ? $exception->getMessage() : '[]'; + + return $this->generateEmptyData($this->config['defaults']['error'], [ + 'message' => $message, + 'type' => $exception::class, + ]); } $additionalDocs = config('auto-doc.additional_paths', []); diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 6e7205d6..5dfeab85 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -238,7 +238,7 @@ public function testGetDocFileContentInvalidTmpData( $content = app(SwaggerService::class)->getDocFileContent(); - $this->assertStringContainsString($this->getFixture($fixture), $content['info']['description']); + $this->assertEqualsFixture($fixture, $content['info']['description']); } public function testEmptyContactEmail() diff --git a/tests/TestCase.php b/tests/TestCase.php index 13242929..4c528394 100755 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -87,7 +87,7 @@ public function assertEqualsJsonFixture(string $fixtureName, $data, bool $export public function assertEqualsFixture(string $fixtureName, $data, bool $exportMode = false): void { if ($exportMode || $this->globalExportMode) { - $this->exportContent($fixtureName, $data); + $this->exportContent($data, $fixtureName); } $this->assertEquals($this->getFixture($fixtureName), $data); diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html index 5ee5a195..b3b59d1d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html @@ -1 +1,11 @@ -Validation failed. paths./users.post.parameters.0 is an array, so it must include an 'items' field. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. paths./users.post.parameters.0 is an array, so it must include an 'items' field. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html index daf4fee1..f6990d54 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html @@ -1 +1,11 @@ -Validation failed. paths./users.get.responses.200.schema is an array, so it must include an 'items' field. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. paths./users.get.responses.200.schema is an array, so it must include an 'items' field. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html index caf830c0..3a8acca3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html @@ -1 +1,11 @@ -Validation failed. paths./users.get.responses.default.headers.Last-Modified is an array, so it must include an 'items' field. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. paths./users.get.responses.default.headers.Last-Modified is an array, so it must include an 'items' field. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html index 389e03a0..903c06d5 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}.post' has body and formData parameters. Only one or the other is allowed. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}.post' has body and formData parameters. Only one or the other is allowed. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html index 0a770041..750b70b8 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}.get' has multiple in:header parameters with name:foo. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\DuplicateParamException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}.get' has multiple in:header parameters with name:foo. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html index 25dbb9bc..f3e281d5 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html @@ -1 +1,11 @@ -Validation failed. Found multiple fields 'paths.*.*.operationId' with values: addPet. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\DuplicateFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Found multiple fields 'paths.*.*.operationId' with values: addPet. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html index a03ed69e..1bae9f4c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}.get' has multiple in:path parameters with name:username. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\DuplicateParamException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}.get' has multiple in:path parameters with name:username. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html index 5e443501..98bdd8f2 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html @@ -1 +1,11 @@ -Validation failed. Path '/users/{username}/profile/{username}/image/{img_id}' has multiple path placeholders with name: username. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\DuplicatePathPlaceholderException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Path '/users/{username}/profile/{username}/image/{img_id}' has multiple path placeholders with name: username. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html index 99344580..000b18e2 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html @@ -1 +1,11 @@ -Validation failed. Found multiple fields 'tags.*.name' with values: user. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\DuplicateFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Found multiple fields 'tags.*.name' with values: user. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html index 22b966e5..a2bb572b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html index 22b966e5..a2bb572b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html index aa91da31..e2690929 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -1 +1,11 @@ -Return value must be of type array, null returned \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 TypeError 🚨🚨 + +--- + +### **Details:** + +[] + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html index a6c49ec3..9bd8cf18 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html @@ -1 +1,11 @@ -Validation failed. Field 'paths./users.get.responses.200.schema.type' has an invalid value: something. Allowed values: array, boolean, integer, number, string, object, null, undefined, file. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidFieldValueException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Field 'paths./users.get.responses.200.schema.type' has an invalid value: something. Allowed values: array, boolean, integer, number, string, object, null, undefined, file. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html index 68a11aac..420049e2 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html @@ -1 +1,11 @@ -Validation failed. Field 'paths./auth/login.post.parameters.0.in' has an invalid value: invalid_in. Allowed values: body, formData, query, path, header. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidFieldValueException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Field 'paths./auth/login.post.parameters.0.in' has an invalid value: invalid_in. Allowed values: body, formData, query, path, header. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html index 96de275c..5652180b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html @@ -1 +1,11 @@ -Validation failed. Incorrect 'paths.users'. Paths should only have path names that starts with `/`. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidPathException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Incorrect 'paths.users'. Paths should only have path names that starts with `/`. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html index 07d68cac..e00f8f6d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html @@ -1 +1,11 @@ -Validation failed. Operation at 'paths./users.get.responses.8888' should only have three-digit status codes, `default`, and vendor extensions (`x-*`) as properties. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidStatusCodeException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation at 'paths./users.get.responses.8888' should only have three-digit status codes, `default`, and vendor extensions (`x-*`) as properties. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html index 2eace1cf..03ed7df9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html @@ -1 +1,11 @@ -Validation failed. Ref 'authloginObject' is used in $ref but not defined in 'tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json' file. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingExternalRefException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Ref 'authloginObject' is used in $ref but not defined in 'tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json' file. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html index e2bd233c..1bd47469 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html @@ -1 +1,11 @@ -Validation failed. 'components.schemas.authloginObject' should have required fields: type. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'components.schemas.authloginObject' should have required fields: type. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html index 28a5c4ff..f81aacb3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html @@ -1 +1,11 @@ -Validation failed. 'paths./user/login.get.responses.200.headers.X-Rate-Limit' should have required fields: type. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./user/login.get.responses.200.headers.X-Rate-Limit' should have required fields: type. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html index dc3dac19..f17fbeb5 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html @@ -1 +1,11 @@ -Validation failed. 'info' should have required fields: version. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'info' should have required fields: version. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html index 0e470070..67ab26af 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html @@ -1 +1,11 @@ -Validation failed. 'paths./pet/findByStatus.get.parameters.0.schema.items' should have required fields: type. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./pet/findByStatus.get.parameters.0.schema.items' should have required fields: type. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html index 5ebd060b..eca8a087 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html @@ -1 +1,11 @@ -Validation failed. 'paths./auth/login.post' should have required fields: responses. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./auth/login.post' should have required fields: responses. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html index 996315fa..3c5488be 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html @@ -1 +1,11 @@ -Validation failed. 'paths./auth/login.post.parameters.0' should have required fields: in. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./auth/login.post.parameters.0' should have required fields: in. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html index c68f537e..640f4c70 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html @@ -1 +1,11 @@ -Validation failed. '' should have required fields: paths. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. '' should have required fields: paths. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html index c272c3d5..7bbd9bb1 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html @@ -1 +1,11 @@ -Validation failed. 'paths./auth/login.post.responses.200' should have required fields: description. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./auth/login.post.responses.200' should have required fields: description. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html index 54dece06..8cecf072 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html @@ -1 +1,11 @@ -Validation failed. 'tags.0' should have required fields: name. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'tags.0' should have required fields: name. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html index 13d8fc9a..e990dbf6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html @@ -1 +1,11 @@ -Validation failed. Ref 'loginObject' is used in $ref but not defined in 'definitions' field. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingLocalRefException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Ref 'loginObject' is used in $ref but not defined in 'definitions' field. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html index 46a71416..e8b8f597 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html @@ -1 +1,11 @@ -Validation failed. Path parameters cannot be optional. Set required=true for the 'username' parameters at operation 'paths./users.get'. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Path parameters cannot be optional. Set required=true for the 'username' parameters at operation 'paths./users.get'. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html index a7794cf8..dde77bcf 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html @@ -1 +1,11 @@ -Validation failed. Filename 'invalid-filename.json' is used in $ref but file doesn't exist. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingRefFileException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Filename 'invalid-filename.json' is used in $ref but file doesn't exist. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html index 3eaab7d4..8d22c659 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}.get' has 2 body parameters. Only one is allowed. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}.get' has 2 body parameters. Only one is allowed. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html index 543b42ff..0bb9a5b2 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}/{foo}.get' has no params for placeholders: username, foo. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingPathParamException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}/{foo}.get' has no params for placeholders: username, foo. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html index 1e350309..69a05e87 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{username}.post' has no placeholders for params: foo. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingPathPlaceholderException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{username}.post' has no placeholders for params: foo. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html index 0884fddc..fa9ecd17 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html @@ -1 +1,11 @@ -Validation failed. Operation 'paths./users/{id}.post' has invalid content types: image/png. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Operation 'paths./users/{id}.post' has invalid content types: image/png. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html index 8e42aa1f..203ba2d1 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html @@ -1 +1,11 @@ -Validation failed. 'paths./users/{id}.post.responses.200.schema.items' should have required fields: type. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingFieldException 🚨🚨 + +--- + +### **Details:** + +Validation failed. 'paths./users/{id}.post.responses.200.schema.items' should have required fields: type. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html index 3e0fc9b6..4e895c16 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html @@ -1 +1,11 @@ -Validation failed. Field 'securityDefinitions.0.flow' has an invalid value: invalid. Allowed values: implicit, password, application, accessCode. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidFieldValueException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Field 'securityDefinitions.0.flow' has an invalid value: invalid. Allowed values: implicit, password, application, accessCode. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html index 241f6946..3b9674ab 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html @@ -1 +1,11 @@ -Validation failed. Field 'securityDefinitions.0.in' has an invalid value: invalid. Allowed values: query, header. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidFieldValueException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Field 'securityDefinitions.0.in' has an invalid value: invalid. Allowed values: query, header. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html index 33a2c0a9..698cbf07 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html @@ -1 +1,11 @@ -Validation failed. Field 'securityDefinitions.0.type' has an invalid value: invalid. Allowed values: basic, apiKey, oauth2. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidFieldValueException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Field 'securityDefinitions.0.type' has an invalid value: invalid. Allowed values: basic, apiKey, oauth2. + +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_version.html b/tests/fixtures/SwaggerServiceTest/invalid_version.html index 581fef92..a205d576 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_version.html @@ -1 +1,11 @@ -Validation failed. Unrecognized Swagger version '1.0'. Expected 3.1.0. \ No newline at end of file +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerVersionException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Unrecognized Swagger version '1.0'. Expected 3.1.0. + +--- \ No newline at end of file From fe96b4b80b1c770e713f9767e1d912e263967fe8 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 9 Jul 2025 17:04:12 +0300 Subject: [PATCH 03/29] refactor: add empty email exception message to view --- src/Services/SwaggerService.php | 7 ++++++- tests/SwaggerServiceTest.php | 4 +++- .../SwaggerServiceTest/invalid_config_email.html | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/SwaggerServiceTest/invalid_config_email.html diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 5a718701..76793862 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -137,7 +137,12 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - throw new EmptyContactEmailException(); + $exception = new EmptyContactEmailException(); + + $viewData = [ + 'message' => $exception->getMessage(), + 'type' => $exception::class, + ]; } if (empty($view) && !empty($this->config['info'])) { diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 5dfeab85..5c476ef1 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -245,7 +245,9 @@ public function testEmptyContactEmail() { config(['auto-doc.info.contact.email' => null]); - $this->expectException(EmptyContactEmailException::class); + $content = app(SwaggerService::class)->getDocFileContent(); + + $this->assertEqualsFixture('invalid_config_email.html', $content['info']['description'], true); app(SwaggerService::class); } diff --git a/tests/fixtures/SwaggerServiceTest/invalid_config_email.html b/tests/fixtures/SwaggerServiceTest/invalid_config_email.html new file mode 100644 index 00000000..8162a684 --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/invalid_config_email.html @@ -0,0 +1,11 @@ +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\EmptyContactEmailException 🚨🚨 + +--- + +### **Details:** + +Please fill the `info.contact.email` field in the app-doc.php config file. + +--- \ No newline at end of file From 241a8f70222df9f03ad4c8cb926b67adc0294780 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 9 Jul 2025 18:03:18 +0300 Subject: [PATCH 04/29] fix: remove useless --- tests/SwaggerServiceTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 5c476ef1..2bf57f74 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -4,7 +4,6 @@ use Illuminate\Http\Testing\File; use PHPUnit\Framework\Attributes\DataProvider; -use RonasIT\AutoDoc\Exceptions\EmptyContactEmailException; use RonasIT\AutoDoc\Exceptions\InvalidDriverClassException; use RonasIT\AutoDoc\Exceptions\LegacyConfigException; use RonasIT\AutoDoc\Exceptions\SwaggerDriverClassNotFoundException; From 6624b40e02497e666918610d5910725ea574288a Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 1 Sep 2025 13:45:29 +0300 Subject: [PATCH 05/29] refactor: add defaul unhandled error message --- config/auto-doc.php | 2 ++ src/Services/SwaggerService.php | 4 +++- tests/SwaggerServiceTest.php | 2 -- ...alid_format_incorrect_documentation_structure_request.html | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config/auto-doc.php b/config/auto-doc.php index 4245ad74..dfebfc75 100644 --- a/config/auto-doc.php +++ b/config/auto-doc.php @@ -110,6 +110,8 @@ | You can use your custom description view for errors. */ 'error' => 'auto-doc::error', + + 'unhandled_error_message' => 'Documentation file is empty or have bad format', ], /* diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 76793862..fb8772fb 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -837,7 +837,9 @@ public function getDocFileContent() $this->openAPIValidator->validate($documentation); } catch (Throwable $exception) { - $message = $exception instanceof Exception ? $exception->getMessage() : '[]'; + $message = ($exception instanceof Exception) + ? $exception->getMessage() + : config('auto-doc.defaults.unhandled_error_message'); return $this->generateEmptyData($this->config['defaults']['error'], [ 'message' => $message, diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 2bf57f74..05d119d8 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -247,8 +247,6 @@ public function testEmptyContactEmail() $content = app(SwaggerService::class)->getDocFileContent(); $this->assertEqualsFixture('invalid_config_email.html', $content['info']['description'], true); - - app(SwaggerService::class); } public static function getAddEmptyData(): array diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html index e2690929..625b3c12 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -6,6 +6,6 @@ ### **Details:** -[] +Documentation file is empty or have bad format --- \ No newline at end of file From 79d523c60b563c36c656c0397d49b62f3ec37df9 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Thu, 11 Sep 2025 17:10:04 +0300 Subject: [PATCH 06/29] refactor: use try catch --- src/Services/SwaggerService.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index fb8772fb..4eed6b6f 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -136,9 +136,11 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], { // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called - if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - $exception = new EmptyContactEmailException(); - + try { + if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { + throw new EmptyContactEmailException(); + } + } catch (EmptyContactEmailException $exception) { $viewData = [ 'message' => $exception->getMessage(), 'type' => $exception::class, From 66d348a4d318f9929a177f15e918c31ce783d399 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Fri, 12 Sep 2025 18:05:12 +0300 Subject: [PATCH 07/29] refactor: use try catch in correct place --- src/Services/SwaggerService.php | 69 +++++++++++++++++---------------- tests/SwaggerServiceTest.php | 6 ++- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 4eed6b6f..5861df96 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -136,22 +136,28 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], { // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called - try { - if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - throw new EmptyContactEmailException(); - } - } catch (EmptyContactEmailException $exception) { - $viewData = [ - 'message' => $exception->getMessage(), - 'type' => $exception::class, - ]; + if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { + throw new EmptyContactEmailException(); } if (empty($view) && !empty($this->config['info'])) { $view = $this->config['info']['description']; } - $data = [ + $data = $this->prepareEmptyData($view, $viewData, $license); + + $securityDefinitions = $this->generateSecurityDefinition(); + + if (!empty($securityDefinitions)) { + $data['securityDefinitions'] = $securityDefinitions; + } + + return $data; + } + + protected function prepareEmptyData(?string $view = null, array $viewData = [], array $license = []): array + { + return [ 'openapi' => self::OPEN_API_VERSION, 'servers' => [ ['url' => URL::query($this->config['basePath'])], @@ -162,14 +168,6 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], ], 'info' => $this->prepareInfo($view, $viewData, $license), ]; - - $securityDefinitions = $this->generateSecurityDefinition(); - - if (!empty($securityDefinitions)) { - $data['securityDefinitions'] = $securityDefinitions; - } - - return $data; } protected function generateSecurityDefinition(): ?array @@ -803,18 +801,6 @@ protected function getActionName($uri): string return Str::camel($action); } - /** - * @deprecated method is not in use - * @codeCoverageIgnore - */ - protected function saveTempData() - { - $exportFile = Arr::get($this->config, 'files.temporary'); - $data = json_encode($this->data); - - file_put_contents($exportFile, $data); - } - public function saveProductionData() { if (ParallelTesting::token()) { @@ -843,10 +829,7 @@ public function getDocFileContent() ? $exception->getMessage() : config('auto-doc.defaults.unhandled_error_message'); - return $this->generateEmptyData($this->config['defaults']['error'], [ - 'message' => $message, - 'type' => $exception::class, - ]); + return $this->generateDataWithExceptionHandling($message, $exception); } $additionalDocs = config('auto-doc.additional_paths', []); @@ -866,6 +849,24 @@ public function getDocFileContent() return $documentation; } + protected function generateDataWithExceptionHandling(string $message, Throwable $exception): array + { + try { + return $this->generateEmptyData($this->config['defaults']['error'], [ + 'message' => $message, + 'type' => $exception::class, + ]); + } catch (EmptyContactEmailException $emptyEmailException) { + return $this->prepareEmptyData( + $this->config['defaults']['error'], + [ + 'message' => $emptyEmailException->getMessage(), + 'type' => $emptyEmailException::class, + ], + ); + } + } + protected function camelCaseToUnderScore($input): string { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 05d119d8..3b32a981 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -15,6 +15,7 @@ use RonasIT\AutoDoc\Tests\Support\Mock\TestRequest; use RonasIT\AutoDoc\Tests\Support\Traits\SwaggerServiceMockTrait; use stdClass; +use RonasIT\AutoDoc\Exceptions\EmptyContactEmailException; class SwaggerServiceTest extends TestCase { @@ -246,7 +247,10 @@ public function testEmptyContactEmail() $content = app(SwaggerService::class)->getDocFileContent(); - $this->assertEqualsFixture('invalid_config_email.html', $content['info']['description'], true); + $this->assertEqualsFixture('invalid_config_email.html', $content['info']['description']); + + $this->expectException(EmptyContactEmailException::class); + $this->expectExceptionMessage('Please fill the `info.contact.email` field in the app-doc.php config file.'); } public static function getAddEmptyData(): array From c48e7f2dfb25b9bce7b726224761f13440d3cdbd Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 17 Sep 2025 15:53:42 +0300 Subject: [PATCH 08/29] fix: tests --- src/Services/SwaggerService.php | 13 ++++++++--- tests/SwaggerServiceTest.php | 23 +++++++++++++++---- ...html => invalid_contact_email_format.html} | 0 3 files changed, 29 insertions(+), 7 deletions(-) rename tests/fixtures/SwaggerServiceTest/{invalid_config_email.html => invalid_contact_email_format.html} (100%) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 5861df96..38ee799e 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -136,9 +136,7 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], { // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called - if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - throw new EmptyContactEmailException(); - } + $this->checkEmail(); if (empty($view) && !empty($this->config['info'])) { $view = $this->config['info']['description']; @@ -155,6 +153,13 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], return $data; } + protected function checkEmail(): void + { + if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { + throw new EmptyContactEmailException(); + } + } + protected function prepareEmptyData(?string $view = null, array $viewData = [], array $license = []): array { return [ @@ -821,6 +826,8 @@ public function saveProductionData() public function getDocFileContent() { try { + $this->checkEmail(); + $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 3b32a981..99dee1a8 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -245,12 +245,27 @@ public function testEmptyContactEmail() { config(['auto-doc.info.contact.email' => null]); - $content = app(SwaggerService::class)->getDocFileContent(); - - $this->assertEqualsFixture('invalid_config_email.html', $content['info']['description']); - $this->expectException(EmptyContactEmailException::class); $this->expectExceptionMessage('Please fill the `info.contact.email` field in the app-doc.php config file.'); + + app(SwaggerService::class)->getDocFileContent(); + } + + public function testGetJSONDocumentationEmailIsNull() + { + config( + [ + 'auto-doc.info.contact.email' => null, + 'app.env' => 'development', + ], + ); + + $content = app(SwaggerService::class)->getDocFileContent(); + + $this->assertEqualsFixture( + 'invalid_contact_email_format.html', + $content['info']['description'] + ); } public static function getAddEmptyData(): array diff --git a/tests/fixtures/SwaggerServiceTest/invalid_config_email.html b/tests/fixtures/SwaggerServiceTest/invalid_contact_email_format.html similarity index 100% rename from tests/fixtures/SwaggerServiceTest/invalid_config_email.html rename to tests/fixtures/SwaggerServiceTest/invalid_contact_email_format.html From 86a3613ebd660f4f7d5ef40a5e6c2104efc96a2b Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 17 Sep 2025 15:57:50 +0300 Subject: [PATCH 09/29] refactor: remove useless --- src/Services/SwaggerService.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 38ee799e..5861df96 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -136,7 +136,9 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], { // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called - $this->checkEmail(); + if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { + throw new EmptyContactEmailException(); + } if (empty($view) && !empty($this->config['info'])) { $view = $this->config['info']['description']; @@ -153,13 +155,6 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], return $data; } - protected function checkEmail(): void - { - if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - throw new EmptyContactEmailException(); - } - } - protected function prepareEmptyData(?string $view = null, array $viewData = [], array $license = []): array { return [ @@ -826,8 +821,6 @@ public function saveProductionData() public function getDocFileContent() { try { - $this->checkEmail(); - $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); From 2d6f29429b6e15586a675c04439d35681c002730 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 24 Sep 2025 16:29:30 +0300 Subject: [PATCH 10/29] style:fix --- config/auto-doc.php | 2 -- lang/en/validation.php | 5 +++++ resources/views/error.blade.php | 2 +- src/AutoDocServiceProvider.php | 2 ++ src/Services/SwaggerService.php | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 lang/en/validation.php diff --git a/config/auto-doc.php b/config/auto-doc.php index dfebfc75..4245ad74 100644 --- a/config/auto-doc.php +++ b/config/auto-doc.php @@ -110,8 +110,6 @@ | You can use your custom description view for errors. */ 'error' => 'auto-doc::error', - - 'unhandled_error_message' => 'Documentation file is empty or have bad format', ], /* diff --git a/lang/en/validation.php b/lang/en/validation.php new file mode 100644 index 00000000..3a271245 --- /dev/null +++ b/lang/en/validation.php @@ -0,0 +1,5 @@ + 'Documentation file is empty or have bad format', +]; \ No newline at end of file diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php index 9e1b884a..b10f9681 100644 --- a/resources/views/error.blade.php +++ b/resources/views/error.blade.php @@ -6,6 +6,6 @@ ### **Details:** -{{$message}} +{{ $message }} --- \ No newline at end of file diff --git a/src/AutoDocServiceProvider.php b/src/AutoDocServiceProvider.php index fafd6bcb..672c6fe3 100644 --- a/src/AutoDocServiceProvider.php +++ b/src/AutoDocServiceProvider.php @@ -11,6 +11,8 @@ public function boot() { $this->mergeConfigFrom(__DIR__ . '/../config/auto-doc.php', 'auto-doc'); + $this->loadTranslationsFrom(__DIR__ . '/../lang', 'auto-doc'); + $this->publishes([ __DIR__ . '/../config/auto-doc.php' => config_path('auto-doc.php'), ], 'config'); diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 5861df96..a18f7351 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -827,7 +827,7 @@ public function getDocFileContent() } catch (Throwable $exception) { $message = ($exception instanceof Exception) ? $exception->getMessage() - : config('auto-doc.defaults.unhandled_error_message'); + : __('validation.unhandled_error_message'); return $this->generateDataWithExceptionHandling($message, $exception); } From 2baa6e40387356290f42f812b8c1d9b544be4e51 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Sun, 28 Sep 2025 22:43:36 +0300 Subject: [PATCH 11/29] refactor: remove generateDataWithExceptionHandling --- src/Services/SwaggerService.php | 47 ++++++++++--------- tests/AutoDocControllerTest.php | 16 +++++++ .../documentation_without_email.json | 25 ++++++++++ 3 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 tests/fixtures/AutoDocControllerTest/documentation_without_email.json diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index a18f7351..ab5222e1 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -136,9 +136,7 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], { // client must enter at least `contact.email` to generate a default `info` block // otherwise an exception will be called - if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { - throw new EmptyContactEmailException(); - } + $this->checkEmail(); if (empty($view) && !empty($this->config['info'])) { $view = $this->config['info']['description']; @@ -155,6 +153,13 @@ protected function generateEmptyData(?string $view = null, array $viewData = [], return $data; } + protected function checkEmail(): void + { + if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) { + throw new EmptyContactEmailException(); + } + } + protected function prepareEmptyData(?string $view = null, array $viewData = [], array $license = []): array { return [ @@ -821,15 +826,31 @@ public function saveProductionData() public function getDocFileContent() { try { + $this->checkEmail(); + $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); + } catch (EmptyContactEmailException $exception) { + return $this->prepareEmptyData( + $this->config['defaults']['error'], + [ + 'message' => $exception->getMessage(), + 'type' => $exception::class, + ], + ); } catch (Throwable $exception) { $message = ($exception instanceof Exception) ? $exception->getMessage() : __('validation.unhandled_error_message'); - return $this->generateDataWithExceptionHandling($message, $exception); + return $this->generateEmptyData( + $this->config['defaults']['error'], + [ + 'message' => $message, + 'type' => $exception::class, + ] + ); } $additionalDocs = config('auto-doc.additional_paths', []); @@ -849,24 +870,6 @@ public function getDocFileContent() return $documentation; } - protected function generateDataWithExceptionHandling(string $message, Throwable $exception): array - { - try { - return $this->generateEmptyData($this->config['defaults']['error'], [ - 'message' => $message, - 'type' => $exception::class, - ]); - } catch (EmptyContactEmailException $emptyEmailException) { - return $this->prepareEmptyData( - $this->config['defaults']['error'], - [ - 'message' => $emptyEmailException->getMessage(), - 'type' => $emptyEmailException::class, - ], - ); - } - } - protected function camelCaseToUnderScore($input): string { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); diff --git a/tests/AutoDocControllerTest.php b/tests/AutoDocControllerTest.php index cf9141d8..ddb0e0af 100644 --- a/tests/AutoDocControllerTest.php +++ b/tests/AutoDocControllerTest.php @@ -40,6 +40,22 @@ public function testGetJSONDocumentation() $response->assertJson(self::$documentation); } + public function testGetJSONWithoutEmailDocumentation() + { + config( + [ + 'auto-doc.info.contact.email' => null, + 'app.env' => 'development', + ], + ); + + $response = $this->json('get', '/auto-doc/documentation'); + + $response->assertStatus(Response::HTTP_OK); + + $this->assertEqualsJsonFixture('documentation_without_email', $response->json()); + } + public function testGetJSONDocumentationWithAdditionalPaths() { config([ diff --git a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json new file mode 100644 index 00000000..49c4d4e9 --- /dev/null +++ b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json @@ -0,0 +1,25 @@ +{ + "openapi": "3.1.0", + "servers": [ + { + "url": "http:\/\/localhost" + } + ], + "paths": [], + "components": { + "schemas": [] + }, + "info": { + "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n---", + "version": "0.0.0", + "title": "Name of Your Application", + "termsOfService": "", + "contact": { + "email": null + }, + "license": { + "name": "", + "url": "" + } + } +} \ No newline at end of file From b8c8e88593aa04ba1bdabc6f5c9a64cf646ca9c7 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 29 Sep 2025 14:13:53 +0300 Subject: [PATCH 12/29] style:fix --- lang/en/validation.php | 2 +- tests/AutoDocControllerTest.php | 10 ++++------ tests/SwaggerServiceTest.php | 19 +------------------ 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/lang/en/validation.php b/lang/en/validation.php index 3a271245..18eeb1f3 100644 --- a/lang/en/validation.php +++ b/lang/en/validation.php @@ -2,4 +2,4 @@ return [ 'unhandled_error_message' => 'Documentation file is empty or have bad format', -]; \ No newline at end of file +]; diff --git a/tests/AutoDocControllerTest.php b/tests/AutoDocControllerTest.php index ddb0e0af..bb7ab7c9 100644 --- a/tests/AutoDocControllerTest.php +++ b/tests/AutoDocControllerTest.php @@ -42,12 +42,10 @@ public function testGetJSONDocumentation() public function testGetJSONWithoutEmailDocumentation() { - config( - [ - 'auto-doc.info.contact.email' => null, - 'app.env' => 'development', - ], - ); + config([ + 'auto-doc.info.contact.email' => null, + 'app.env' => 'development', + ]); $response = $this->json('get', '/auto-doc/documentation'); diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 99dee1a8..e627bc61 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -250,24 +250,7 @@ public function testEmptyContactEmail() app(SwaggerService::class)->getDocFileContent(); } - - public function testGetJSONDocumentationEmailIsNull() - { - config( - [ - 'auto-doc.info.contact.email' => null, - 'app.env' => 'development', - ], - ); - - $content = app(SwaggerService::class)->getDocFileContent(); - - $this->assertEqualsFixture( - 'invalid_contact_email_format.html', - $content['info']['description'] - ); - } - + public static function getAddEmptyData(): array { return [ From c779d3382326705a2e52a5fdd5f9286d26be0c2a Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 17:11:15 +0300 Subject: [PATCH 13/29] refactor: mock getTraceMethod --- resources/views/error.blade.php | 5 +- src/Services/SwaggerService.php | 76 +++++++++------- tests/SwaggerServiceTest.php | 4 +- .../documentation__non_json.txt | 90 ------------------- .../documentation_without_email.json | 2 +- ...valid_format_array_parameter_no_items.html | 3 + ...d_format_array_response_body_no_items.html | 3 + ...format_array_response_header_no_items.html | 3 + .../invalid_format_body_and_form_params.html | 3 + ...nvalid_format_duplicate_header_params.html | 3 + ...invalid_format_duplicate_operation_id.html | 3 + .../invalid_format_duplicate_path_params.html | 3 + ...id_format_duplicate_path_placeholders.html | 3 + .../invalid_format_duplicate_tag.html | 3 + .../invalid_format_file_invalid_consumes.html | 3 + .../invalid_format_file_no_consumes.html | 3 + ...rrect_documentation_structure_request.html | 3 + .../invalid_format_invalid_schema_type.html | 3 + ...lid_format_invalid_value_parameter_in.html | 3 + .../invalid_format_invalid_value_path.html | 3 + ...alid_format_invalid_value_status_code.html | 3 + .../invalid_format_missing_external_ref.html | 3 + ..._format_missing_field_definition_type.html | 3 + ...alid_format_missing_field_header_type.html | 3 + ...lid_format_missing_field_info_version.html | 3 + ...valid_format_missing_field_items_type.html | 3 + ...mat_missing_field_operation_responses.html | 3 + ...lid_format_missing_field_parameter_in.html | 3 + .../invalid_format_missing_field_paths.html | 3 + ...at_missing_field_response_description.html | 3 + ...invalid_format_missing_field_tag_name.html | 3 + .../invalid_format_missing_local_ref.html | 3 + ...invalid_format_missing_path_parameter.html | 3 + .../invalid_format_missing_ref_file.html | 3 + .../invalid_format_multiple_body_params.html | 3 + .../invalid_format_no_path_params.html | 3 + ...alid_format_path_param_no_placeholder.html | 3 + ...d_format_request_body_invalid_content.html | 3 + ...invalid_format_response_invalid_items.html | 3 + ...valid_format_security_definition_flow.html | 3 + ...invalid_format_security_definition_in.html | 3 + ...valid_format_security_definition_type.html | 3 + .../SwaggerServiceTest/invalid_version.html | 3 + .../Traits/SwaggerServiceMockTrait.php | 49 ++++++++++ 44 files changed, 217 insertions(+), 123 deletions(-) delete mode 100644 tests/fixtures/AutoDocControllerTest/documentation__non_json.txt diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php index b10f9681..de4ceeb3 100644 --- a/resources/views/error.blade.php +++ b/resources/views/error.blade.php @@ -1,6 +1,6 @@ # ❗️ **ERROR** ❗️ -## 🚨🚨 {{$type}} 🚨🚨 +## 🚨🚨 {{ $type }} 🚨🚨 --- @@ -8,4 +8,7 @@ {{ $message }} +### **Error place:** + +{{ $error_place }} --- \ No newline at end of file diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index ab5222e1..715e5721 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -25,6 +25,7 @@ use Symfony\Component\HttpFoundation\Response; use Throwable; use Exception; + /** * @property SwaggerDriverContract $driver */ @@ -73,6 +74,10 @@ public function __construct(Container $container) $this->setDriver(); if (config('app.env') === 'testing') { + // client must enter at least `contact.email` to generate a default `info` block + // otherwise an exception will be called + $this->checkEmail(); + $this->container = $container; $this->security = $this->config['security']; @@ -84,6 +89,23 @@ public function __construct(Container $container) $this->driver->saveProcessTmpData($this->data); } + } else { + try { + $this->checkEmail(); + } catch (EmptyContactEmailException $exception) { + $this->data = $this->generateEmptyData( + $this->config['defaults']['error'], + [ + 'message' => $exception->getMessage(), + 'type' => $exception::class, + 'error_place' => $this->getErrorPlace($exception), + ], + ); + + $this->driver->saveProcessTmpData($this->data); + + $this->driver->saveData(); + } } } @@ -134,15 +156,21 @@ protected function setDriver() protected function generateEmptyData(?string $view = null, array $viewData = [], array $license = []): array { - // client must enter at least `contact.email` to generate a default `info` block - // otherwise an exception will be called - $this->checkEmail(); - if (empty($view) && !empty($this->config['info'])) { $view = $this->config['info']['description']; } - $data = $this->prepareEmptyData($view, $viewData, $license); + $data = [ + 'openapi' => self::OPEN_API_VERSION, + 'servers' => [ + ['url' => URL::query($this->config['basePath'])], + ], + 'paths' => [], + 'components' => [ + 'schemas' => $this->config['definitions'], + ], + 'info' => $this->prepareInfo($view, $viewData, $license), + ]; $securityDefinitions = $this->generateSecurityDefinition(); @@ -160,21 +188,6 @@ protected function checkEmail(): void } } - protected function prepareEmptyData(?string $view = null, array $viewData = [], array $license = []): array - { - return [ - 'openapi' => self::OPEN_API_VERSION, - 'servers' => [ - ['url' => URL::query($this->config['basePath'])], - ], - 'paths' => [], - 'components' => [ - 'schemas' => $this->config['definitions'], - ], - 'info' => $this->prepareInfo($view, $viewData, $license), - ]; - } - protected function generateSecurityDefinition(): ?array { if (empty($this->security)) { @@ -826,19 +839,9 @@ public function saveProductionData() public function getDocFileContent() { try { - $this->checkEmail(); - $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); - } catch (EmptyContactEmailException $exception) { - return $this->prepareEmptyData( - $this->config['defaults']['error'], - [ - 'message' => $exception->getMessage(), - 'type' => $exception::class, - ], - ); } catch (Throwable $exception) { $message = ($exception instanceof Exception) ? $exception->getMessage() @@ -849,6 +852,7 @@ public function getDocFileContent() [ 'message' => $message, 'type' => $exception::class, + 'error_place' => $this->getErrorPlace($exception), ] ); } @@ -870,6 +874,18 @@ public function getDocFileContent() return $documentation; } + protected function getErrorPlace(Throwable $exception): string + { + $errorPlaceInTrace = Arr::first($exception->getTrace()); + + $errorPlaceInTrace = implode(', ', Arr::map( + $errorPlaceInTrace, + fn ($value, $key) => $key . '=' . (is_array($value) ? json_encode($value) : $value), + )); + + return $errorPlaceInTrace; + } + protected function camelCaseToUnderScore($input): string { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index e627bc61..d6d5edd6 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -238,6 +238,8 @@ public function testGetDocFileContentInvalidTmpData( $content = app(SwaggerService::class)->getDocFileContent(); + $this->mockGetTrace($content['info']['description']); + $this->assertEqualsFixture($fixture, $content['info']['description']); } @@ -250,7 +252,7 @@ public function testEmptyContactEmail() app(SwaggerService::class)->getDocFileContent(); } - + public static function getAddEmptyData(): array { return [ diff --git a/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt b/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt deleted file mode 100644 index ba9562d7..00000000 --- a/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt +++ /dev/null @@ -1,90 +0,0 @@ -openapi: "3.1.0", -info: - description: "This is a sample server Petstore server." - version: "1.0.0" - title: "Swagger Petstore 2.0" - termsOfService: "http://swagger.io/terms/" - contact: - email: "apiteam@swagger.io" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" -host: "petstore.swagger.io" -basePath: "/v2" -tags: -- name: "pet" - description: "Everything about your Pets" - externalDocs: - description: "Find out more" - url: "http://swagger.io" -- name: "store" - description: "Access to Petstore orders" -- name: "user" - description: "Operations about user" - externalDocs: - description: "Find out more about our store" - url: "http://swagger.io" -schemes: -- "https" -- "http" -paths: - /pet: - post: - tags: - - "pet" - summary: "Add a new pet to the store" - description: "" - operationId: "addPet" - - parameters: - - in: "body" - name: "body" - description: "Pet object that needs to be added to the store" - required: true - schema: - $ref: "#/definitions/Pet" - responses: - "405": - description: "Invalid input" - security: - - petstore_auth: - - "write:pets" - - "read:pets" -definitions: - Pet: - type: "object" - required: - - "name" - - "photoUrls" - properties: - id: - type: "integer" - format: "int64" - category: - $ref: "#/definitions/Category" - name: - type: "string" - example: "doggie" - photoUrls: - type: "array" - xml: - name: "photoUrl" - wrapped: true - items: - type: "string" - tags: - type: "array" - xml: - name: "tag" - wrapped: true - items: - $ref: "#/definitions/Tag" - status: - type: "string" - description: "pet status in the store" - enum: - - "available" - - "pending" - - "sold" - xml: - name: "Pet" diff --git a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json index 49c4d4e9..ebfed48d 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json +++ b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json @@ -10,7 +10,7 @@ "schemas": [] }, "info": { - "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n---", + "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n### **Error place:**\n\nfile=\/app\/src\/Services\/SwaggerService.php, line=94, function=checkEmail, class=RonasIT\\AutoDoc\\Services\\SwaggerService, type=->, args=[]\n---", "version": "0.0.0", "title": "Name of Your Application", "termsOfService": "", diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html index b3b59d1d..754c82ce 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html @@ -8,4 +8,7 @@ Validation failed. paths./users.post.parameters.0 is an array, so it must include an 'items' field. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined"],"paths.\/users.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html index f6990d54..12f50651 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html @@ -8,4 +8,7 @@ Validation failed. paths./users.get.responses.200.schema is an array, so it must include an 'items' field. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html index 3a8acca3..ccbdfb47 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html @@ -8,4 +8,7 @@ Validation failed. paths./users.get.responses.default.headers.Last-Modified is an array, so it must include an 'items' field. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","date","double"],"paths.\/users.get.responses.default.headers.Last-Modified"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html index 903c06d5..6a3709d0 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}.post' has body and formData parameters. Only one or the other is allowed. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"body","schema":{"type":"number"}},{"name":"bar","in":"formData","schema":{"type":"number"}}],"paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html index 750b70b8..87dd8675 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}.get' has multiple in:header parameters with name:foo. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html index f3e281d5..e45159da 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html @@ -8,4 +8,7 @@ Validation failed. Found multiple fields 'paths.*.*.operationId' with values: addPet. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateOperationIdsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html index 1bae9f4c..7efb2b92 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}.get' has multiple in:path parameters with name:username. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"username","in":"path","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html index 98bdd8f2..df82a5dc 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html @@ -8,4 +8,7 @@ Validation failed. Path '/users/{username}/profile/{username}/image/{img_id}' has multiple path placeholders with name: username. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"img_id","in":"path","required":true,"schema":{"type":"number"}}],"\/users\/{username}\/profile\/{username}\/image\/{img_id}","paths.\/users\/{username}\/profile\/{username}\/image\/{img_id}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html index 000b18e2..09f6161e 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html @@ -8,4 +8,7 @@ Validation failed. Found multiple fields 'tags.*.name' with values: user. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateTagsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html index a2bb572b..53eed4a0 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"consumes":["application\/octet-stream","image\/png"],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html index a2bb572b..31690a7d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}/profile/image.post' has body and formData parameters. Only one or the other is allowed. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html index 625b3c12..34024aed 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -8,4 +8,7 @@ Documentation file is empty or have bad format +### **Error place:** + +file=/app/src/Services/SwaggerService.php, 999, function=getDocumentation, MockClass, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html index 9bd8cf18..e9b26f5d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html @@ -8,4 +8,7 @@ Validation failed. Field 'paths./users.get.responses.200.schema.type' has an invalid value: something. Allowed values: array, boolean, integer, number, string, object, null, undefined, file. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"something","items":{"user":{"type":"string"}}},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html index 420049e2..0f76d47a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html @@ -8,4 +8,7 @@ Validation failed. Field 'paths./auth/login.post.parameters.0.in' has an invalid value: invalid_in. Allowed values: body, formData, query, path, header. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["paths.\/auth\/login.post.parameters.0.in",["body","formData","query","path","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html index 5652180b..5ac7e76d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html @@ -8,4 +8,7 @@ Validation failed. Incorrect 'paths.users'. Paths should only have path names that starts with `/`. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePaths, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html index e00f8f6d..2058d69f 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html @@ -8,4 +8,7 @@ Validation failed. Operation at 'paths./users.get.responses.8888' should only have three-digit status codes, `default`, and vendor extensions (`x-*`) as properties. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateResponse, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"description":"hello world"},"8888","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html index 03ed7df9..602f5aed 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_external_ref.html @@ -8,4 +8,7 @@ Validation failed. Ref 'authloginObject' is used in $ref but not defined in 'tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json' file. +### **Error place:** + +function=RonasIT\AutoDoc\Validators\{closure}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["tests\/fixtures\/SwaggerServiceTest\/documentation\/with_definitions.json#\/definitions\/authloginObject","$ref"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html index 1bd47469..26bf95fd 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html @@ -8,4 +8,7 @@ Validation failed. 'components.schemas.authloginObject' should have required fields: type. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"components.schemas.authloginObject"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html index f81aacb3..d2632e33 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html @@ -8,4 +8,7 @@ Validation failed. 'paths./user/login.get.responses.200.headers.X-Rate-Limit' should have required fields: type. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/user\/login.get.responses.200.headers.X-Rate-Limit"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html index f17fbeb5..5e9da536 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html @@ -8,4 +8,7 @@ Validation failed. 'info' should have required fields: version. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["title","version"],"info"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html index 67ab26af..b4dd942c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html @@ -8,4 +8,7 @@ Validation failed. 'paths./pet/findByStatus.get.parameters.0.schema.items' should have required fields: type. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/pet\/findByStatus.get.parameters.0.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html index eca8a087..81aabcf6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html @@ -8,4 +8,7 @@ Validation failed. 'paths./auth/login.post' should have required fields: responses. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["responses"],"paths.\/auth\/login.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html index 3c5488be..5dcca334 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html @@ -8,4 +8,7 @@ Validation failed. 'paths./auth/login.post.parameters.0' should have required fields: in. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["in","name"],"paths.\/auth\/login.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html index 640f4c70..d3c9dfe9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html @@ -8,4 +8,7 @@ Validation failed. '' should have required fields: paths. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["openapi","info","paths"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html index 7bbd9bb1..1aec013c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html @@ -8,4 +8,7 @@ Validation failed. 'paths./auth/login.post.responses.200' should have required fields: description. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["description"],"paths.\/auth\/login.post.responses.200"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html index 8cecf072..c0b68fb6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html @@ -8,4 +8,7 @@ Validation failed. 'tags.0' should have required fields: name. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["name"],"tags.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html index e990dbf6..30a369f9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_local_ref.html @@ -8,4 +8,7 @@ Validation failed. Ref 'loginObject' is used in $ref but not defined in 'definitions' field. +### **Error place:** + +function=RonasIT\AutoDoc\Validators\{closure}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["#\/definitions\/loginObject","$ref"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html index e8b8f597..5ec89ce7 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html @@ -8,4 +8,7 @@ Validation failed. Path parameters cannot be optional. Set required=true for the 'username' parameters at operation 'paths./users.get'. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}}],"\/users","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html index dde77bcf..e9a773e7 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_ref_file.html @@ -8,4 +8,7 @@ Validation failed. Filename 'invalid-filename.json' is used in $ref but file doesn't exist. +### **Error place:** + +function=RonasIT\AutoDoc\Validators\{closure}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["invalid-filename.json","$ref"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html index 8d22c659..b6a02dc4 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}.get' has 2 body parameters. Only one is allowed. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"number"},"required":true},{"name":"foo","in":"body","required":true,"schema":{"type":"number"}},{"name":"foo2","in":"body","schema":{"type":"number"}}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html index 0bb9a5b2..697fcf6f 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}/{foo}.get' has no params for placeholders: username, foo. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"header","required":true,"schema":{"type":"number"}},{"name":"foo","in":"body","schema":{"type":"number"}}],"\/users\/{username}\/{foo}","paths.\/users\/{username}\/{foo}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html index 69a05e87..10c3b9cb 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{username}.post' has no placeholders for params: foo. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"path","schema":{"type":"number"}}],"\/users\/{username}","paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html index fa9ecd17..82fc865d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html @@ -8,4 +8,7 @@ Validation failed. Operation 'paths./users/{id}.post' has invalid content types: image/png. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateRequestBodyContent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"image\/png":{"items":[]}},"paths.\/users\/{id}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html index 203ba2d1..3c68fce3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html @@ -8,4 +8,7 @@ Validation failed. 'paths./users/{id}.post.responses.200.schema.items' should have required fields: type. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/users\/{id}.post.responses.200.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html index 4e895c16..d53751e0 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html @@ -8,4 +8,7 @@ Validation failed. Field 'securityDefinitions.0.flow' has an invalid value: invalid. Allowed values: implicit, password, application, accessCode. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.flow",["implicit","password","application","accessCode"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html index 3b9674ab..d78a9e65 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html @@ -8,4 +8,7 @@ Validation failed. Field 'securityDefinitions.0.in' has an invalid value: invalid. Allowed values: query, header. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.in",["query","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html index 698cbf07..0f096224 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html @@ -8,4 +8,7 @@ Validation failed. Field 'securityDefinitions.0.type' has an invalid value: invalid. Allowed values: basic, apiKey, oauth2. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.type",["basic","apiKey","oauth2"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_version.html b/tests/fixtures/SwaggerServiceTest/invalid_version.html index a205d576..ba5ff471 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_version.html @@ -8,4 +8,7 @@ Validation failed. Unrecognized Swagger version '1.0'. Expected 3.1.0. +### **Error place:** + +file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateVersion, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/support/Traits/SwaggerServiceMockTrait.php b/tests/support/Traits/SwaggerServiceMockTrait.php index 8c47d2bb..9d155148 100644 --- a/tests/support/Traits/SwaggerServiceMockTrait.php +++ b/tests/support/Traits/SwaggerServiceMockTrait.php @@ -4,6 +4,14 @@ use RonasIT\AutoDoc\Drivers\LocalDriver; use RonasIT\Support\Traits\MockTrait; +use RonasIT\AutoDoc\Services\SwaggerService; +use Illuminate\Container\Container; +use Mockery; +use Mockery\MockInterface; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; + +use function PHPUnit\Framework\callback; trait SwaggerServiceMockTrait { @@ -68,4 +76,45 @@ protected function mockDriverSaveData($driverClass = LocalDriver::class): void $this->functionCall('saveData'), ]); } + + protected function mockGetTrace(string &$content): void + { + $contentInArray = explode(PHP_EOL, $content); + + $traceInfo = Arr::first( + array: $contentInArray, + callback: fn ($value, $key) => Str::containsAll($value, ['args', 'class']) + ); + + $traceInfoInArray = $this->gerTraceInfoInArray($traceInfo); + + $mockedContent = Arr::set( + array: $contentInArray, + key: array_search($traceInfo, $contentInArray), + value: implode(', ', $traceInfoInArray) + ); + + $content = implode(PHP_EOL, $mockedContent); + } + + protected function gerTraceInfoInArray(string $traceInfo): array + { + $errorPlaceInArray = explode(', ', $traceInfo); + $errorPlaceInArray = array_combine( + keys: Arr::map($errorPlaceInArray, fn ($value, $key) => Str::before($value, '=')), + values: $errorPlaceInArray + ); + + foreach ($errorPlaceInArray as $key => $value) { + if ($key === 'line') { + $errorPlaceInArray[$key] = 999; + } + + if ($key === 'class' && Str::contains($value, 'MockObject')) { + $errorPlaceInArray[$key] = 'MockClass'; + } + } + + return $errorPlaceInArray; + } } From b5f10584e34c03ea82c6238a8867872704e45157 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 17:23:10 +0300 Subject: [PATCH 14/29] fix: make correct trace format --- .../invalid_format_array_parameter_no_items.html | 2 +- .../invalid_format_array_response_body_no_items.html | 2 +- .../invalid_format_array_response_header_no_items.html | 2 +- .../invalid_format_body_and_form_params.html | 2 +- .../invalid_format_duplicate_header_params.html | 2 +- .../invalid_format_duplicate_operation_id.html | 2 +- .../invalid_format_duplicate_path_params.html | 2 +- .../invalid_format_duplicate_path_placeholders.html | 2 +- .../SwaggerServiceTest/invalid_format_duplicate_tag.html | 2 +- .../invalid_format_file_invalid_consumes.html | 2 +- .../SwaggerServiceTest/invalid_format_file_no_consumes.html | 2 +- ...alid_format_incorrect_documentation_structure_request.html | 2 +- .../invalid_format_invalid_schema_type.html | 2 +- .../invalid_format_invalid_value_parameter_in.html | 2 +- .../SwaggerServiceTest/invalid_format_invalid_value_path.html | 2 +- .../invalid_format_invalid_value_status_code.html | 2 +- .../invalid_format_missing_field_definition_type.html | 2 +- .../invalid_format_missing_field_header_type.html | 2 +- .../invalid_format_missing_field_info_version.html | 2 +- .../invalid_format_missing_field_items_type.html | 2 +- .../invalid_format_missing_field_operation_responses.html | 2 +- .../invalid_format_missing_field_parameter_in.html | 2 +- .../invalid_format_missing_field_paths.html | 2 +- .../invalid_format_missing_field_response_description.html | 2 +- .../invalid_format_missing_field_tag_name.html | 2 +- .../invalid_format_missing_path_parameter.html | 2 +- .../invalid_format_multiple_body_params.html | 2 +- .../SwaggerServiceTest/invalid_format_no_path_params.html | 2 +- .../invalid_format_path_param_no_placeholder.html | 2 +- .../invalid_format_request_body_invalid_content.html | 2 +- .../invalid_format_response_invalid_items.html | 2 +- .../invalid_format_security_definition_flow.html | 2 +- .../invalid_format_security_definition_in.html | 2 +- .../invalid_format_security_definition_type.html | 2 +- tests/fixtures/SwaggerServiceTest/invalid_version.html | 2 +- tests/support/Traits/SwaggerServiceMockTrait.php | 4 ++-- 36 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html index 754c82ce..a4efb182 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined"],"paths.\/users.post.parameters.0"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined"],"paths.\/users.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html index 12f50651..283f9288 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html index ccbdfb47..97bda741 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","date","double"],"paths.\/users.get.responses.default.headers.Last-Modified"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","date","double"],"paths.\/users.get.responses.default.headers.Last-Modified"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html index 6a3709d0..24e9b137 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"body","schema":{"type":"number"}},{"name":"bar","in":"formData","schema":{"type":"number"}}],"paths.\/users\/{username}.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"body","schema":{"type":"number"}},{"name":"bar","in":"formData","schema":{"type":"number"}}],"paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html index 87dd8675..aeac17b4 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html index e45159da..777704ae 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateOperationIdsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateOperationIdsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html index 7efb2b92..5cd58a07 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"username","in":"path","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"username","in":"path","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html index df82a5dc..fd840cb1 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"img_id","in":"path","required":true,"schema":{"type":"number"}}],"\/users\/{username}\/profile\/{username}\/image\/{img_id}","paths.\/users\/{username}\/profile\/{username}\/image\/{img_id}.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"img_id","in":"path","required":true,"schema":{"type":"number"}}],"\/users\/{username}\/profile\/{username}\/image\/{img_id}","paths.\/users\/{username}\/profile\/{username}\/image\/{img_id}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html index 09f6161e..8bc521ad 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateTagsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateTagsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html index 53eed4a0..75c8b8ee 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"consumes":["application\/octet-stream","image\/png"],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"consumes":["application\/octet-stream","image\/png"],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html index 31690a7d..c6e36708 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html index 34024aed..7ee61ea5 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Services/SwaggerService.php, 999, function=getDocumentation, MockClass, type=->, args=[] +file=/app/src/Services/SwaggerService.php, line=999, function=getDocumentation, class=MockClass, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html index e9b26f5d..a8af1bf6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"something","items":{"user":{"type":"string"}}},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"something","items":{"user":{"type":"string"}}},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html index 0f76d47a..3b6771c9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["paths.\/auth\/login.post.parameters.0.in",["body","formData","query","path","header"]] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["paths.\/auth\/login.post.parameters.0.in",["body","formData","query","path","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html index 5ac7e76d..a780b7c0 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePaths, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePaths, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html index 2058d69f..5a7cabf9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateResponse, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"description":"hello world"},"8888","paths.\/users.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateResponse, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"description":"hello world"},"8888","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html index 26bf95fd..66ced634 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"components.schemas.authloginObject"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"components.schemas.authloginObject"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html index d2632e33..8eac3285 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/user\/login.get.responses.200.headers.X-Rate-Limit"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/user\/login.get.responses.200.headers.X-Rate-Limit"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html index 5e9da536..9336bbea 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["title","version"],"info"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["title","version"],"info"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html index b4dd942c..e80ebda9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/pet\/findByStatus.get.parameters.0.schema.items"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/pet\/findByStatus.get.parameters.0.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html index 81aabcf6..de59ebb8 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["responses"],"paths.\/auth\/login.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["responses"],"paths.\/auth\/login.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html index 5dcca334..7e5fe86e 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["in","name"],"paths.\/auth\/login.post.parameters.0"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["in","name"],"paths.\/auth\/login.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html index d3c9dfe9..24170790 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["openapi","info","paths"]] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["openapi","info","paths"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html index 1aec013c..7274f18c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["description"],"paths.\/auth\/login.post.responses.200"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["description"],"paths.\/auth\/login.post.responses.200"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html index c0b68fb6..6d33da78 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["name"],"tags.0"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["name"],"tags.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html index 5ec89ce7..641df7c6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}}],"\/users","paths.\/users.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}}],"\/users","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html index b6a02dc4..bc2dbdb3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"number"},"required":true},{"name":"foo","in":"body","required":true,"schema":{"type":"number"}},{"name":"foo2","in":"body","schema":{"type":"number"}}],"paths.\/users\/{username}.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"number"},"required":true},{"name":"foo","in":"body","required":true,"schema":{"type":"number"}},{"name":"foo2","in":"body","schema":{"type":"number"}}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html index 697fcf6f..bf317e29 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"header","required":true,"schema":{"type":"number"}},{"name":"foo","in":"body","schema":{"type":"number"}}],"\/users\/{username}\/{foo}","paths.\/users\/{username}\/{foo}.get"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"header","required":true,"schema":{"type":"number"}},{"name":"foo","in":"body","schema":{"type":"number"}}],"\/users\/{username}\/{foo}","paths.\/users\/{username}\/{foo}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html index 10c3b9cb..2a70611d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"path","schema":{"type":"number"}}],"\/users\/{username}","paths.\/users\/{username}.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"path","schema":{"type":"number"}}],"\/users\/{username}","paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html index 82fc865d..0db80265 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateRequestBodyContent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"image\/png":{"items":[]}},"paths.\/users\/{id}.post"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateRequestBodyContent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"image\/png":{"items":[]}},"paths.\/users\/{id}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html index 3c68fce3..e3d72f11 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/users\/{id}.post.responses.200.schema.items"] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/users\/{id}.post.responses.200.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html index d53751e0..719073a9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.flow",["implicit","password","application","accessCode"]] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.flow",["implicit","password","application","accessCode"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html index d78a9e65..7c1bbc77 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.in",["query","header"]] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.in",["query","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html index 0f096224..e33b2902 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.type",["basic","apiKey","oauth2"]] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.type",["basic","apiKey","oauth2"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_version.html b/tests/fixtures/SwaggerServiceTest/invalid_version.html index ba5ff471..ed0f59cd 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_version.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, 999, function=validateVersion, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateVersion, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/support/Traits/SwaggerServiceMockTrait.php b/tests/support/Traits/SwaggerServiceMockTrait.php index 9d155148..7ed4d852 100644 --- a/tests/support/Traits/SwaggerServiceMockTrait.php +++ b/tests/support/Traits/SwaggerServiceMockTrait.php @@ -107,11 +107,11 @@ protected function gerTraceInfoInArray(string $traceInfo): array foreach ($errorPlaceInArray as $key => $value) { if ($key === 'line') { - $errorPlaceInArray[$key] = 999; + $errorPlaceInArray[$key] = 'line=999'; } if ($key === 'class' && Str::contains($value, 'MockObject')) { - $errorPlaceInArray[$key] = 'MockClass'; + $errorPlaceInArray[$key] = 'class=MockClass'; } } From e91f3c75dbdac69501f176106756a74d76c3db96 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 17:50:18 +0300 Subject: [PATCH 15/29] refactor: make TraceMockTrait --- tests/AutoDocControllerTest.php | 8 ++- tests/SwaggerServiceTest.php | 2 + .../documentation_without_email.json | 2 +- .../Traits/SwaggerServiceMockTrait.php | 49 ------------------ tests/support/Traits/TraceMockTrait.php | 50 +++++++++++++++++++ 5 files changed, 60 insertions(+), 51 deletions(-) create mode 100644 tests/support/Traits/TraceMockTrait.php diff --git a/tests/AutoDocControllerTest.php b/tests/AutoDocControllerTest.php index bb7ab7c9..ab8534c2 100644 --- a/tests/AutoDocControllerTest.php +++ b/tests/AutoDocControllerTest.php @@ -4,10 +4,12 @@ use Illuminate\Http\Response; use phpmock\phpunit\PHPMock; +use RonasIT\AutoDoc\Tests\Support\Traits\TraceMockTrait; class AutoDocControllerTest extends TestCase { use PHPMock; + use TraceMockTrait; protected static array $documentation; protected static string $localDriverFilePath; @@ -51,7 +53,11 @@ public function testGetJSONWithoutEmailDocumentation() $response->assertStatus(Response::HTTP_OK); - $this->assertEqualsJsonFixture('documentation_without_email', $response->json()); + $content = $response->json(); + + $this->mockGetTrace($content['info']['description']); + + $this->assertEqualsJsonFixture('documentation_without_email', $content); } public function testGetJSONDocumentationWithAdditionalPaths() diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index d6d5edd6..5c28b59d 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -16,10 +16,12 @@ use RonasIT\AutoDoc\Tests\Support\Traits\SwaggerServiceMockTrait; use stdClass; use RonasIT\AutoDoc\Exceptions\EmptyContactEmailException; +use RonasIT\AutoDoc\Tests\Support\Traits\TraceMockTrait; class SwaggerServiceTest extends TestCase { use SwaggerServiceMockTrait; + use TraceMockTrait; public function testConstructorInvalidConfigVersion() { diff --git a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json index ebfed48d..7c27cb3c 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json +++ b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json @@ -10,7 +10,7 @@ "schemas": [] }, "info": { - "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n### **Error place:**\n\nfile=\/app\/src\/Services\/SwaggerService.php, line=94, function=checkEmail, class=RonasIT\\AutoDoc\\Services\\SwaggerService, type=->, args=[]\n---", + "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n### **Error place:**\n\nfile=\/app\/src\/Services\/SwaggerService.php, line=999, function=checkEmail, class=RonasIT\\AutoDoc\\Services\\SwaggerService, type=->, args=[]\n---", "version": "0.0.0", "title": "Name of Your Application", "termsOfService": "", diff --git a/tests/support/Traits/SwaggerServiceMockTrait.php b/tests/support/Traits/SwaggerServiceMockTrait.php index 7ed4d852..8c47d2bb 100644 --- a/tests/support/Traits/SwaggerServiceMockTrait.php +++ b/tests/support/Traits/SwaggerServiceMockTrait.php @@ -4,14 +4,6 @@ use RonasIT\AutoDoc\Drivers\LocalDriver; use RonasIT\Support\Traits\MockTrait; -use RonasIT\AutoDoc\Services\SwaggerService; -use Illuminate\Container\Container; -use Mockery; -use Mockery\MockInterface; -use Illuminate\Support\Arr; -use Illuminate\Support\Str; - -use function PHPUnit\Framework\callback; trait SwaggerServiceMockTrait { @@ -76,45 +68,4 @@ protected function mockDriverSaveData($driverClass = LocalDriver::class): void $this->functionCall('saveData'), ]); } - - protected function mockGetTrace(string &$content): void - { - $contentInArray = explode(PHP_EOL, $content); - - $traceInfo = Arr::first( - array: $contentInArray, - callback: fn ($value, $key) => Str::containsAll($value, ['args', 'class']) - ); - - $traceInfoInArray = $this->gerTraceInfoInArray($traceInfo); - - $mockedContent = Arr::set( - array: $contentInArray, - key: array_search($traceInfo, $contentInArray), - value: implode(', ', $traceInfoInArray) - ); - - $content = implode(PHP_EOL, $mockedContent); - } - - protected function gerTraceInfoInArray(string $traceInfo): array - { - $errorPlaceInArray = explode(', ', $traceInfo); - $errorPlaceInArray = array_combine( - keys: Arr::map($errorPlaceInArray, fn ($value, $key) => Str::before($value, '=')), - values: $errorPlaceInArray - ); - - foreach ($errorPlaceInArray as $key => $value) { - if ($key === 'line') { - $errorPlaceInArray[$key] = 'line=999'; - } - - if ($key === 'class' && Str::contains($value, 'MockObject')) { - $errorPlaceInArray[$key] = 'class=MockClass'; - } - } - - return $errorPlaceInArray; - } } diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php new file mode 100644 index 00000000..3ffa1158 --- /dev/null +++ b/tests/support/Traits/TraceMockTrait.php @@ -0,0 +1,50 @@ + Str::containsAll($value, ['args', 'class']) + ); + + $traceInfoInArray = $this->gerTraceInfoInArray($traceInfo); + + $mockedContent = Arr::set( + array: $contentInArray, + key: array_search($traceInfo, $contentInArray), + value: implode(', ', $traceInfoInArray) + ); + + $content = implode(PHP_EOL, $mockedContent); + } + + protected function gerTraceInfoInArray(string $traceInfo): array + { + $errorPlaceInArray = explode(', ', $traceInfo); + $errorPlaceInArray = array_combine( + keys: Arr::map($errorPlaceInArray, fn ($value, $key) => Str::before($value, '=')), + values: $errorPlaceInArray + ); + + foreach ($errorPlaceInArray as $key => $value) { + if ($key === 'line') { + $errorPlaceInArray[$key] = 'line=999'; + } + + if ($key === 'class' && Str::contains($value, 'MockObject')) { + $errorPlaceInArray[$key] = 'class=MockClass'; + } + } + + return $errorPlaceInArray; + } +} \ No newline at end of file From 500b9dfc40ae1b1342ef644ffc4311145fb4498e Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 17:55:34 +0300 Subject: [PATCH 16/29] style:fix --- tests/AutoDocControllerTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/AutoDocControllerTest.php b/tests/AutoDocControllerTest.php index ab8534c2..8a39cd95 100644 --- a/tests/AutoDocControllerTest.php +++ b/tests/AutoDocControllerTest.php @@ -8,8 +8,7 @@ class AutoDocControllerTest extends TestCase { - use PHPMock; - use TraceMockTrait; + use PHPMock, TraceMockTrait; protected static array $documentation; protected static string $localDriverFilePath; From 9cc86e5b98e1efd6c339ed37399fbda4386d491f Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 18:08:01 +0300 Subject: [PATCH 17/29] style:fix --- tests/support/Traits/TraceMockTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 3ffa1158..40a9ee15 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -16,7 +16,7 @@ protected function mockGetTrace(string &$content): void callback: fn ($value, $key) => Str::containsAll($value, ['args', 'class']) ); - $traceInfoInArray = $this->gerTraceInfoInArray($traceInfo); + $traceInfoInArray = $this->getTraceInfoInArray($traceInfo); $mockedContent = Arr::set( array: $contentInArray, @@ -27,7 +27,7 @@ protected function mockGetTrace(string &$content): void $content = implode(PHP_EOL, $mockedContent); } - protected function gerTraceInfoInArray(string $traceInfo): array + protected function getTraceInfoInArray(string $traceInfo): array { $errorPlaceInArray = explode(', ', $traceInfo); $errorPlaceInArray = array_combine( From 9bc0e270c247a3f3ca1724da82af621fa973ccad Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Mon, 6 Oct 2025 18:08:01 +0300 Subject: [PATCH 18/29] style:fix --- tests/support/Traits/TraceMockTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 3ffa1158..9497f615 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -13,10 +13,10 @@ protected function mockGetTrace(string &$content): void $traceInfo = Arr::first( array: $contentInArray, - callback: fn ($value, $key) => Str::containsAll($value, ['args', 'class']) + callback: fn ($value, $key) => Str::containsAll($value, ['arg', 'class']) ); - $traceInfoInArray = $this->gerTraceInfoInArray($traceInfo); + $traceInfoInArray = $this->getTraceInfoInArray($traceInfo); $mockedContent = Arr::set( array: $contentInArray, @@ -27,7 +27,7 @@ protected function mockGetTrace(string &$content): void $content = implode(PHP_EOL, $mockedContent); } - protected function gerTraceInfoInArray(string $traceInfo): array + protected function getTraceInfoInArray(string $traceInfo): array { $errorPlaceInArray = explode(', ', $traceInfo); $errorPlaceInArray = array_combine( From 0d5d70e2831d111710109c41e3d91c49a1cdbdce Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Tue, 7 Oct 2025 16:10:51 +0300 Subject: [PATCH 19/29] fix: correct find trace info in response content --- tests/support/Traits/TraceMockTrait.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 9497f615..61c49181 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -13,7 +13,7 @@ protected function mockGetTrace(string &$content): void $traceInfo = Arr::first( array: $contentInArray, - callback: fn ($value, $key) => Str::containsAll($value, ['arg', 'class']) + callback: fn ($value, $key) => Str::contains($value, 'function=') ); $traceInfoInArray = $this->getTraceInfoInArray($traceInfo); @@ -36,13 +36,11 @@ protected function getTraceInfoInArray(string $traceInfo): array ); foreach ($errorPlaceInArray as $key => $value) { - if ($key === 'line') { - $errorPlaceInArray[$key] = 'line=999'; - } - - if ($key === 'class' && Str::contains($value, 'MockObject')) { - $errorPlaceInArray[$key] = 'class=MockClass'; - } + $errorPlaceInArray[$key] = match ($key) { + 'line' => 'line=999', + 'class' => Str::contains($value, 'MockObject') ? 'class=MockClass' : $value, + default => $value, + }; } return $errorPlaceInArray; From 99e0fc5ed150e9173e954fde47e26e8662c7dd2a Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Tue, 7 Oct 2025 17:46:24 +0300 Subject: [PATCH 20/29] refactor: make tests for github ci env --- .github/workflows/run-tests-with-coverage.yml | 2 +- tests/support/Traits/TraceMockTrait.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests-with-coverage.yml b/.github/workflows/run-tests-with-coverage.yml index 4d4ab568..204e51c4 100644 --- a/.github/workflows/run-tests-with-coverage.yml +++ b/.github/workflows/run-tests-with-coverage.yml @@ -24,7 +24,7 @@ jobs: - name: Install Dependencies run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Execute unit tests via PHPUnit with coverage - run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml + run: php -d zend.exception_ignore_args=0 -d xdebug.collect_params=4 vendor/bin/phpunit --coverage-clover build/logs/clover.xml - name: Export coverage report if: ${{ matrix.php-version == '8.4' }} uses: actions/upload-artifact@v4 diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 61c49181..33e93943 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -39,10 +39,20 @@ protected function getTraceInfoInArray(string $traceInfo): array $errorPlaceInArray[$key] = match ($key) { 'line' => 'line=999', 'class' => Str::contains($value, 'MockObject') ? 'class=MockClass' : $value, + 'file' => $this->normalizeFilePath($value), default => $value, }; } return $errorPlaceInArray; } + + protected function normalizeFilePath(string $filePath): string + { + if (!str_starts_with($filePath, '/app')) { + return Str::after($filePath, base_path() . DIRECTORY_SEPARATOR); + } + + return $filePath; + } } \ No newline at end of file From 986846577d2b80aec7fd22dac08f5abded34301f Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Tue, 7 Oct 2025 18:04:52 +0300 Subject: [PATCH 21/29] fix:tests --- .../AutoDocControllerTest/documentation_without_email.json | 2 +- .../invalid_format_array_parameter_no_items.html | 2 +- .../invalid_format_array_response_body_no_items.html | 2 +- .../invalid_format_array_response_header_no_items.html | 2 +- .../SwaggerServiceTest/invalid_format_body_and_form_params.html | 2 +- .../invalid_format_duplicate_header_params.html | 2 +- .../invalid_format_duplicate_operation_id.html | 2 +- .../invalid_format_duplicate_path_params.html | 2 +- .../invalid_format_duplicate_path_placeholders.html | 2 +- .../SwaggerServiceTest/invalid_format_duplicate_tag.html | 2 +- .../invalid_format_file_invalid_consumes.html | 2 +- .../SwaggerServiceTest/invalid_format_file_no_consumes.html | 2 +- ...nvalid_format_incorrect_documentation_structure_request.html | 2 +- .../SwaggerServiceTest/invalid_format_invalid_schema_type.html | 2 +- .../invalid_format_invalid_value_parameter_in.html | 2 +- .../SwaggerServiceTest/invalid_format_invalid_value_path.html | 2 +- .../invalid_format_invalid_value_status_code.html | 2 +- .../invalid_format_missing_field_definition_type.html | 2 +- .../invalid_format_missing_field_header_type.html | 2 +- .../invalid_format_missing_field_info_version.html | 2 +- .../invalid_format_missing_field_items_type.html | 2 +- .../invalid_format_missing_field_operation_responses.html | 2 +- .../invalid_format_missing_field_parameter_in.html | 2 +- .../SwaggerServiceTest/invalid_format_missing_field_paths.html | 2 +- .../invalid_format_missing_field_response_description.html | 2 +- .../invalid_format_missing_field_tag_name.html | 2 +- .../invalid_format_missing_path_parameter.html | 2 +- .../SwaggerServiceTest/invalid_format_multiple_body_params.html | 2 +- .../SwaggerServiceTest/invalid_format_no_path_params.html | 2 +- .../invalid_format_path_param_no_placeholder.html | 2 +- .../invalid_format_request_body_invalid_content.html | 2 +- .../invalid_format_response_invalid_items.html | 2 +- .../invalid_format_security_definition_flow.html | 2 +- .../invalid_format_security_definition_in.html | 2 +- .../invalid_format_security_definition_type.html | 2 +- tests/fixtures/SwaggerServiceTest/invalid_version.html | 2 +- tests/support/Traits/TraceMockTrait.php | 2 +- 37 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json index 7c27cb3c..382b20c2 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation_without_email.json +++ b/tests/fixtures/AutoDocControllerTest/documentation_without_email.json @@ -10,7 +10,7 @@ "schemas": [] }, "info": { - "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n### **Error place:**\n\nfile=\/app\/src\/Services\/SwaggerService.php, line=999, function=checkEmail, class=RonasIT\\AutoDoc\\Services\\SwaggerService, type=->, args=[]\n---", + "description": "# ❗️ **ERROR** ❗️\n\n## 🚨🚨 RonasIT\\AutoDoc\\Exceptions\\EmptyContactEmailException 🚨🚨\n\n---\n\n### **Details:**\n\nPlease fill the `info.contact.email` field in the app-doc.php config file.\n\n### **Error place:**\n\nfile=\/src\/Services\/SwaggerService.php, line=999, function=checkEmail, class=RonasIT\\AutoDoc\\Services\\SwaggerService, type=->, args=[]\n---", "version": "0.0.0", "title": "Name of Your Application", "termsOfService": "", diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html index a4efb182..497ab12d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_parameter_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined"],"paths.\/users.post.parameters.0"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined"],"paths.\/users.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html index 283f9288..ca505eae 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_body_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html index 97bda741..f7edcb4a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_array_response_header_no_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","date","double"],"paths.\/users.get.responses.default.headers.Last-Modified"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"array"},["array","boolean","integer","number","string","object","date","double"],"paths.\/users.get.responses.default.headers.Last-Modified"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html index 24e9b137..4260f82c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_body_and_form_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"body","schema":{"type":"number"}},{"name":"bar","in":"formData","schema":{"type":"number"}}],"paths.\/users\/{username}.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"body","schema":{"type":"number"}},{"name":"bar","in":"formData","schema":{"type":"number"}}],"paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html index aeac17b4..d97ab16a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_header_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"foo","in":"header","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html index 777704ae..27cb7ff9 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_operation_id.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateOperationIdsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateOperationIdsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html index 5cd58a07..b30a1771 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"username","in":"path","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateParamsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}},{"name":"username","in":"path","schema":{"type":"number"},"required":true}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html index fd840cb1..43432d5b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_path_placeholders.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"img_id","in":"path","required":true,"schema":{"type":"number"}}],"\/users\/{username}\/profile\/{username}\/image\/{img_id}","paths.\/users\/{username}\/profile\/{username}\/image\/{img_id}.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"img_id","in":"path","required":true,"schema":{"type":"number"}}],"\/users\/{username}\/profile\/{username}\/image\/{img_id}","paths.\/users\/{username}\/profile\/{username}\/image\/{img_id}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html index 8bc521ad..cb8ba38a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_duplicate_tag.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateTagsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateTagsUnique, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html index 75c8b8ee..0bf41111 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_invalid_consumes.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"consumes":["application\/octet-stream","image\/png"],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"consumes":["application\/octet-stream","image\/png"],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html index c6e36708..4cae7ff3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_file_no_consumes.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFormDataConsumes, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"parameters":[{"name":"username","in":"path","schema":{"type":"string"},"required":true},{"name":"image","in":"formData","schema":{"type":"file"}}],"responses":{"default":{"description":"hello world"}}},"paths.\/users\/{username}\/profile\/image.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html index 7ee61ea5..51d4f69d 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Services/SwaggerService.php, line=999, function=getDocumentation, class=MockClass, type=->, args=[] +file=/src/Services/SwaggerService.php, line=999, function=getDocumentation, class=MockClass, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html index a8af1bf6..855ad952 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_schema_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"something","items":{"user":{"type":"string"}}},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateType, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"type":"something","items":{"user":{"type":"string"}}},["array","boolean","integer","number","string","object","null","undefined","file"],"paths.\/users.get.responses.200.schema"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html index 3b6771c9..e3085d3f 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_parameter_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["paths.\/auth\/login.post.parameters.0.in",["body","formData","query","path","header"]] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["paths.\/auth\/login.post.parameters.0.in",["body","formData","query","path","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html index a780b7c0..1c19c7f3 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_path.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePaths, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePaths, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html index 5a7cabf9..d332bd91 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_invalid_value_status_code.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateResponse, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"description":"hello world"},"8888","paths.\/users.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateResponse, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"description":"hello world"},"8888","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html index 66ced634..a71f2c82 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_definition_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"components.schemas.authloginObject"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"components.schemas.authloginObject"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html index 8eac3285..16511e5e 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_header_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/user\/login.get.responses.200.headers.X-Rate-Limit"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/user\/login.get.responses.200.headers.X-Rate-Limit"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html index 9336bbea..f577df16 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_info_version.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["title","version"],"info"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["title","version"],"info"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html index e80ebda9..347e99c6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_items_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/pet\/findByStatus.get.parameters.0.schema.items"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/pet\/findByStatus.get.parameters.0.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html index de59ebb8..51f44d2a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_operation_responses.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["responses"],"paths.\/auth\/login.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["responses"],"paths.\/auth\/login.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html index 7e5fe86e..228657f6 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_parameter_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["in","name"],"paths.\/auth\/login.post.parameters.0"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["in","name"],"paths.\/auth\/login.post.parameters.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html index 24170790..8c3f08cc 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_paths.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["openapi","info","paths"]] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["openapi","info","paths"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html index 7274f18c..5b10e3df 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_response_description.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["description"],"paths.\/auth\/login.post.responses.200"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["description"],"paths.\/auth\/login.post.responses.200"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html index 6d33da78..782ca34b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_field_tag_name.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["name"],"tags.0"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["name"],"tags.0"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html index 641df7c6..be45334f 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_missing_path_parameter.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}}],"\/users","paths.\/users.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"string"},"required":false},{"name":"username","in":"header","schema":{"type":"string"}},{"name":"username","in":"body","schema":{"type":"string"}}],"\/users","paths.\/users.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html index bc2dbdb3..a40ab989 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_multiple_body_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"number"},"required":true},{"name":"foo","in":"body","required":true,"schema":{"type":"number"}},{"name":"foo2","in":"body","schema":{"type":"number"}}],"paths.\/users\/{username}.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateBodyParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"bar","in":"header","schema":{"type":"number"},"required":true},{"name":"foo","in":"body","required":true,"schema":{"type":"number"}},{"name":"foo2","in":"body","schema":{"type":"number"}}],"paths.\/users\/{username}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html index bf317e29..d1450f4c 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_no_path_params.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"header","required":true,"schema":{"type":"number"}},{"name":"foo","in":"body","schema":{"type":"number"}}],"\/users\/{username}\/{foo}","paths.\/users\/{username}\/{foo}.get"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"header","required":true,"schema":{"type":"number"}},{"name":"foo","in":"body","schema":{"type":"number"}}],"\/users\/{username}\/{foo}","paths.\/users\/{username}\/{foo}.get"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html index 2a70611d..bbe5b4bd 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_path_param_no_placeholder.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"path","schema":{"type":"number"}}],"\/users\/{username}","paths.\/users\/{username}.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validatePathParameters, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[[{"name":"username","in":"path","required":true,"schema":{"type":"string"}},{"name":"foo","in":"path","schema":{"type":"number"}}],"\/users\/{username}","paths.\/users\/{username}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html index 0db80265..ebfd7c9a 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_request_body_invalid_content.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateRequestBodyContent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"image\/png":{"items":[]}},"paths.\/users\/{id}.post"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateRequestBodyContent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[{"image\/png":{"items":[]}},"paths.\/users\/{id}.post"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html index e3d72f11..5c0f44cd 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_response_invalid_items.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/users\/{id}.post.responses.200.schema.items"] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldsPresent, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[["type"],"paths.\/users\/{id}.post.responses.200.schema.items"] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html index 719073a9..771a4b12 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_flow.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.flow",["implicit","password","application","accessCode"]] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.flow",["implicit","password","application","accessCode"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html index 7c1bbc77..338b923f 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_in.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.in",["query","header"]] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.in",["query","header"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html index e33b2902..2ecc341b 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_security_definition_type.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.type",["basic","apiKey","oauth2"]] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateFieldValue, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["securityDefinitions.0.type",["basic","apiKey","oauth2"]] --- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/invalid_version.html b/tests/fixtures/SwaggerServiceTest/invalid_version.html index ed0f59cd..06889e32 100644 --- a/tests/fixtures/SwaggerServiceTest/invalid_version.html +++ b/tests/fixtures/SwaggerServiceTest/invalid_version.html @@ -10,5 +10,5 @@ ### **Error place:** -file=/app/src/Validators/SwaggerSpecValidator.php, line=999, function=validateVersion, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] +file=/src/Validators/SwaggerSpecValidator.php, line=999, function=validateVersion, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=[] --- \ No newline at end of file diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 33e93943..5c4026be 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -39,7 +39,7 @@ protected function getTraceInfoInArray(string $traceInfo): array $errorPlaceInArray[$key] = match ($key) { 'line' => 'line=999', 'class' => Str::contains($value, 'MockObject') ? 'class=MockClass' : $value, - 'file' => $this->normalizeFilePath($value), + 'file' => 'file=/src' . Str::after($value, '/src'), default => $value, }; } From 33cf5e7212ffd2e6617344d33b6babb135900d6a Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 13:33:51 +0300 Subject: [PATCH 22/29] test --- tests/support/Traits/TraceMockTrait.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 5c4026be..3cac42bd 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -40,6 +40,7 @@ protected function getTraceInfoInArray(string $traceInfo): array 'line' => 'line=999', 'class' => Str::contains($value, 'MockObject') ? 'class=MockClass' : $value, 'file' => 'file=/src' . Str::after($value, '/src'), + 'function' => $this->normalizeClosureFormat($value), default => $value, }; } @@ -55,4 +56,19 @@ protected function normalizeFilePath(string $filePath): string return $filePath; } + + protected function normalizeClosureFormat(string $function): string + { + if (Str::contains($function, 'closure:')) { + $functionInArray = explode(':', $function); + + foreach ($functionInArray as $key => $value) { + $functionInArray[$key] = is_int($value) ? '1' : $value; + } + + return implode(':', $functionInArray); + } + + return $function; + } } \ No newline at end of file From dd35456d4a99195790ebe40a0b61600a0d5f8a2b Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 13:44:55 +0300 Subject: [PATCH 23/29] test --- tests/SwaggerServiceTest.php | 9 +++++++++ ...hp_8.4_invalid_format_missing_external_ref.html | 14 ++++++++++++++ .../php_8.4_invalid_format_missing_local_ref.html | 14 ++++++++++++++ .../php_8.4_invalid_format_missing_ref_file.html | 14 ++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_external_ref.html create mode 100644 tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_local_ref.html create mode 100644 tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_ref_file.html diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 0ca3028e..2bfba99f 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -187,14 +187,17 @@ public static function getConstructorInvalidTmpData(): array [ 'tmpDoc' => 'documentation/invalid_format__missing_local_ref', 'fixture' => 'invalid_format_missing_local_ref.html', + 'eight_dot_four_fixture' => 'php_8.4_invalid_format_missing_local_ref.html' ], [ 'tmpDoc' => 'documentation/invalid_format__missing_external_ref', 'fixture' => 'invalid_format_missing_external_ref.html', + 'eight_dot_four_fixture' => 'php_8.4_invalid_format_missing_external_ref.html' ], [ 'tmpDoc' => 'documentation/invalid_format__missing_ref_file', 'fixture' => 'invalid_format_missing_ref_file.html', + 'eight_dot_four_fixture' => 'php_8.4_invalid_format_missing_ref_file.html' ], [ 'tmpDoc' => 'documentation/invalid_format__invalid_schema_type', @@ -235,6 +238,7 @@ public static function getConstructorInvalidTmpData(): array public function testGetDocFileContentInvalidTmpData( string $tmpDoc, string $fixture, + ?string $eight_dot_four_fixture = null, ) { $this->mockDriverGetDocumentation($this->getJsonFixture($tmpDoc)); @@ -242,6 +246,11 @@ public function testGetDocFileContentInvalidTmpData( $this->mockGetTrace($content['info']['description']); + if (!empty($eight_dot_four_fixture) + && version_compare(PHP_VERSION, '8.4.0', '>=')) { + $this->assertEqualsFixture($eight_dot_four_fixture, $content['info']['description']); + } + $this->assertEqualsFixture($fixture, $content['info']['description']); } diff --git a/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_external_ref.html b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_external_ref.html new file mode 100644 index 00000000..1b2206de --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_external_ref.html @@ -0,0 +1,14 @@ +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingExternalRefException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Ref 'authloginObject' is used in $ref but not defined in 'tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json' file. + +### **Error place:** + +function={closure:RonasIT\AutoDoc\Validators\SwaggerSpecValidator::validateRefs():1}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["tests\/fixtures\/SwaggerServiceTest\/documentation\/with_definitions.json#\/definitions\/authloginObject","$ref"] +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_local_ref.html b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_local_ref.html new file mode 100644 index 00000000..227d8633 --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_local_ref.html @@ -0,0 +1,14 @@ +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingLocalRefException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Ref 'loginObject' is used in $ref but not defined in 'definitions' field. + +### **Error place:** + +function={closure:RonasIT\AutoDoc\Validators\SwaggerSpecValidator::validateRefs():1}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["#\/definitions\/loginObject","$ref"] +--- \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_ref_file.html b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_ref_file.html new file mode 100644 index 00000000..5ce8effe --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/php_8.4_invalid_format_missing_ref_file.html @@ -0,0 +1,14 @@ +# ❗️ **ERROR** ❗️ + +## 🚨🚨 RonasIT\AutoDoc\Exceptions\SpecValidation\MissingRefFileException 🚨🚨 + +--- + +### **Details:** + +Validation failed. Filename 'invalid-filename.json' is used in $ref but file doesn't exist. + +### **Error place:** + +function={closure:RonasIT\AutoDoc\Validators\SwaggerSpecValidator::validateRefs():1}, class=RonasIT\AutoDoc\Validators\SwaggerSpecValidator, type=->, args=["invalid-filename.json","$ref"] +--- \ No newline at end of file From 827a160ecd2e6aa28c0bcf1461e1e55d6991dbd0 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 13:50:48 +0300 Subject: [PATCH 24/29] test --- tests/support/Traits/TraceMockTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 3cac42bd..c0b44b30 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -65,7 +65,7 @@ protected function normalizeClosureFormat(string $function): string foreach ($functionInArray as $key => $value) { $functionInArray[$key] = is_int($value) ? '1' : $value; } - + dd($functionInArray); return implode(':', $functionInArray); } From e3205a5a057af38f78b46ca03a25de408e274793 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 13:56:17 +0300 Subject: [PATCH 25/29] test --- tests/support/Traits/TraceMockTrait.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index c0b44b30..043254b6 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -62,10 +62,8 @@ protected function normalizeClosureFormat(string $function): string if (Str::contains($function, 'closure:')) { $functionInArray = explode(':', $function); - foreach ($functionInArray as $key => $value) { - $functionInArray[$key] = is_int($value) ? '1' : $value; - } - dd($functionInArray); + Arr::set($functionInArray, Arr::last($functionInArray), '1}'); + return implode(':', $functionInArray); } From bd3182f8b6b87d3f767a11876a6831b61aac112e Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 13:59:09 +0300 Subject: [PATCH 26/29] test --- tests/support/Traits/TraceMockTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 043254b6..413772a6 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -61,7 +61,7 @@ protected function normalizeClosureFormat(string $function): string { if (Str::contains($function, 'closure:')) { $functionInArray = explode(':', $function); - + dd($functionInArray); Arr::set($functionInArray, Arr::last($functionInArray), '1}'); return implode(':', $functionInArray); From 4f49531af4e1fd1fed1c20316a6e6d6c0def78bb Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 14:16:27 +0300 Subject: [PATCH 27/29] test --- tests/support/Traits/TraceMockTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index 413772a6..cee46428 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -61,7 +61,7 @@ protected function normalizeClosureFormat(string $function): string { if (Str::contains($function, 'closure:')) { $functionInArray = explode(':', $function); - dd($functionInArray); + dd(Arr::last($functionInArray)); Arr::set($functionInArray, Arr::last($functionInArray), '1}'); return implode(':', $functionInArray); From ae6c2f3a189b74e10ebb292b0628f3e5c9ce48cd Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 14:20:18 +0300 Subject: [PATCH 28/29] test --- tests/support/Traits/TraceMockTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/Traits/TraceMockTrait.php b/tests/support/Traits/TraceMockTrait.php index cee46428..13d39633 100644 --- a/tests/support/Traits/TraceMockTrait.php +++ b/tests/support/Traits/TraceMockTrait.php @@ -61,8 +61,8 @@ protected function normalizeClosureFormat(string $function): string { if (Str::contains($function, 'closure:')) { $functionInArray = explode(':', $function); - dd(Arr::last($functionInArray)); - Arr::set($functionInArray, Arr::last($functionInArray), '1}'); + + Arr::set($functionInArray, array_key_last($functionInArray), '1}'); return implode(':', $functionInArray); } From 15f9f2791698f08ab3a672a19fa0a62e0e3a5201 Mon Sep 17 00:00:00 2001 From: Ruslan Guskov Date: Wed, 8 Oct 2025 14:22:03 +0300 Subject: [PATCH 29/29] test --- tests/SwaggerServiceTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 2bfba99f..8859e294 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -249,9 +249,10 @@ public function testGetDocFileContentInvalidTmpData( if (!empty($eight_dot_four_fixture) && version_compare(PHP_VERSION, '8.4.0', '>=')) { $this->assertEqualsFixture($eight_dot_four_fixture, $content['info']['description']); + } else { + $this->assertEqualsFixture($fixture, $content['info']['description']); } - $this->assertEqualsFixture($fixture, $content['info']['description']); } public function testEmptyContactEmail()