diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php index 0b9291cb..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 b6074986..76793862 100644 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -23,8 +23,8 @@ use RonasIT\AutoDoc\Traits\GetDependenciesTrait; use RonasIT\AutoDoc\Validators\SwaggerSpecValidator; use Symfony\Component\HttpFoundation\Response; +use Throwable; use Exception; - /** * @property SwaggerDriverContract $driver */ @@ -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'])) { @@ -831,8 +836,13 @@ public function getDocFileContent() $documentation = $this->driver->getDocumentation(); $this->openAPIValidator->validate($documentation); - } catch (Exception $exception) { - return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]); + } catch (Throwable $exception) { + $message = $exception instanceof Exception ? $exception->getMessage() : '[]'; + + return $this->generateEmptyData($this->config['defaults']['error'], [ + 'message' => $message, + 'type' => $exception::class, + ]); } $additionalDocs = config('auto-doc.additional_paths', []); @@ -973,7 +983,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..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; @@ -222,6 +221,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', + ], ]; } @@ -241,7 +244,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/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/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_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 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 new file mode 100644 index 00000000..e2690929 --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/invalid_format_incorrect_documentation_structure_request.html @@ -0,0 +1,11 @@ +# ❗️ **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