From 4e3496f30872ce6ecd7b511f0e842e18bf573b20 Mon Sep 17 00:00:00 2001 From: Alexey Vardugin Date: Tue, 27 Aug 2024 14:17:42 +0600 Subject: [PATCH 1/8] feat: updated openapi version to 3.1.0 --- .../SpecValidation/InvalidSwaggerVersionException.php | 2 +- src/Services/SwaggerService.php | 4 ++-- src/Validators/SwaggerSpecValidator.php | 6 +++--- tests/SwaggerServiceTest.php | 2 +- ...documentation__invalid_format__missing_field__paths.json | 2 +- .../AutoDocControllerTest/documentation__non_json.txt | 2 +- tests/fixtures/AutoDocControllerTest/tmp_data.json | 2 +- .../tmp_data_with_additional_paths.json | 4 ++-- .../tmp_data_search_roles_request.json | 4 ++-- tests/fixtures/LocalDriverTest/tmp_data.json | 2 +- tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json | 2 +- .../PushDocumentationCommandTest/documentation.json | 4 ++-- .../tmp_data_search_roles_request.json | 2 +- tests/fixtures/RemoteDriverTest/tmp_data.json | 2 +- tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json | 2 +- tests/fixtures/StorageDriverTest/tmp_data.json | 2 +- .../fixtures/StorageDriverTest/tmp_data_non_formatted.json | 2 +- .../documentation/array_response_header_with_items.json | 4 ++-- .../SwaggerServiceTest/documentation/formdata_request.json | 4 ++-- .../invalid_format__array_parameter__no_items.json | 4 ++-- .../invalid_format__array_response_body__no_items.json | 4 ++-- .../invalid_format__array_response_header__no_items.json | 4 ++-- .../documentation/invalid_format__body_and_form_params.json | 4 ++-- .../invalid_format__duplicate_header_params.json | 4 ++-- .../invalid_format__duplicate_operation_id.json | 4 ++-- .../invalid_format__duplicate_path_params.json | 2 +- .../invalid_format__duplicate_path_placeholders.json | 4 ++-- .../documentation/invalid_format__duplicate_tag.json | 2 +- .../invalid_format__file_invalid_consumes.json | 4 ++-- .../documentation/invalid_format__file_no_consumes.json | 4 ++-- .../documentation/invalid_format__invalid_schema_type.json | 4 ++-- .../invalid_format__invalid_value__parameter_in.json | 2 +- .../documentation/invalid_format__invalid_value__path.json | 4 ++-- .../invalid_format__invalid_value__status_code.json | 4 ++-- .../documentation/invalid_format__missing_external_ref.json | 2 +- .../invalid_format__missing_field__definition_type.json | 2 +- .../invalid_format__missing_field__header_type.json | 4 ++-- .../invalid_format__missing_field__info_version.json | 2 +- .../invalid_format__missing_field__items_type.json | 4 ++-- .../invalid_format__missing_field__operation_responses.json | 2 +- .../invalid_format__missing_field__parameter_in.json | 2 +- .../documentation/invalid_format__missing_field__paths.json | 2 +- ...invalid_format__missing_field__response_description.json | 2 +- .../invalid_format__missing_field__tag_name.json | 4 ++-- .../documentation/invalid_format__missing_local_ref.json | 2 +- .../invalid_format__missing_path_parameter.json | 4 ++-- .../documentation/invalid_format__missing_ref_file.json | 2 +- .../documentation/invalid_format__multiple_body_params.json | 4 ++-- .../documentation/invalid_format__no_path_params.json | 4 ++-- .../invalid_format__path_param_no_placeholder.json | 4 ++-- .../invalid_format__path_placeholder_no_param.json | 4 ++-- .../invalid_format__security_definition__flow.json | 2 +- .../invalid_format__security_definition__in.json | 2 +- .../invalid_format__security_definition__type.json | 2 +- .../SwaggerServiceTest/documentation/invalid_version.json | 4 ++-- .../SwaggerServiceTest/documentation/with_definitions.json | 2 +- .../SwaggerServiceTest/tmp_data_create_user_request.json | 4 ++-- .../tmp_data_get_route_parameters_description.json | 2 +- .../SwaggerServiceTest/tmp_data_get_user_request.json | 2 +- .../SwaggerServiceTest/tmp_data_post_user_request.json | 2 +- .../tmp_data_post_user_request_with_object_params.json | 2 +- .../SwaggerServiceTest/tmp_data_put_user_request.json | 2 +- .../tmp_data_put_user_request_with_early_generated_doc.json | 2 +- .../tmp_data_request_with_empty_data_and_info.json | 4 ++-- .../tmp_data_request_with_empty_data_jwt.json | 4 ++-- .../tmp_data_request_with_empty_data_laravel.json | 4 ++-- .../tmp_data_request_with_empty_data_query.json | 4 ++-- .../tmp_data_search_roles_closure_request.json | 2 +- .../SwaggerServiceTest/tmp_data_search_roles_request.json | 2 +- .../tmp_data_search_roles_request_invalid_content_type.json | 2 +- .../tmp_data_search_roles_request_jwt_security.json | 2 +- .../tmp_data_search_roles_request_laravel_security.json | 2 +- .../tmp_data_search_roles_request_pdf.json | 2 +- .../tmp_data_search_roles_request_plain_text.json | 2 +- .../tmp_data_search_roles_request_query_security.json | 2 +- .../tmp_data_search_roles_request_with_annotations.json | 2 +- .../tmp_data_search_roles_request_without_info.json | 2 +- .../tmp_data_search_roles_request_without_rule_type.json | 2 +- .../tmp_data_search_users_empty_request.json | 4 ++-- .../SwaggerServiceTest/tmp_data_search_users_request.json | 4 ++-- 80 files changed, 116 insertions(+), 116 deletions(-) diff --git a/src/Exceptions/SpecValidation/InvalidSwaggerVersionException.php b/src/Exceptions/SpecValidation/InvalidSwaggerVersionException.php index 1305ad1a..42c5625d 100644 --- a/src/Exceptions/SpecValidation/InvalidSwaggerVersionException.php +++ b/src/Exceptions/SpecValidation/InvalidSwaggerVersionException.php @@ -8,7 +8,7 @@ class InvalidSwaggerVersionException extends InvalidSwaggerSpecException { public function __construct(string $version) { - $expectedVersion = SwaggerService::SWAGGER_VERSION; + $expectedVersion = SwaggerService::OPEN_API_VERSION; parent::__construct("Unrecognized Swagger version '{$version}'. Expected {$expectedVersion}."); } diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 62d76abc..e5442207 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -29,7 +29,7 @@ class SwaggerService { use GetDependenciesTrait; - public const SWAGGER_VERSION = '2.0'; + public const OPEN_API_VERSION = '3.1.0'; protected $driver; protected $openAPIValidator; @@ -138,7 +138,7 @@ protected function generateEmptyData(): array } $data = [ - 'swagger' => self::SWAGGER_VERSION, + 'openapi' => self::OPEN_API_VERSION, 'host' => $this->getAppUrl(), 'basePath' => $this->config['basePath'], 'schemes' => $this->config['schemes'], diff --git a/src/Validators/SwaggerSpecValidator.php b/src/Validators/SwaggerSpecValidator.php index 6895b65b..35b2f1d1 100644 --- a/src/Validators/SwaggerSpecValidator.php +++ b/src/Validators/SwaggerSpecValidator.php @@ -49,7 +49,7 @@ class SwaggerSpecValidator public const REQUIRED_FIELDS = [ 'definition' => ['type'], - 'doc' => ['swagger', 'info', 'paths'], + 'doc' => ['openapi', 'info', 'paths'], 'info' => ['title', 'version'], 'item' => ['type'], 'header' => ['type'], @@ -96,9 +96,9 @@ public function validate(array $doc): void protected function validateVersion(): void { - $version = Arr::get($this->doc, 'swagger', ''); + $version = Arr::get($this->doc, 'openapi', ''); - if (version_compare($version, SwaggerService::SWAGGER_VERSION, '!=')) { + if (version_compare($version, SwaggerService::OPEN_API_VERSION, '!=')) { throw new InvalidSwaggerVersionException($version); } } diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 0e61c9a6..00398d02 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -89,7 +89,7 @@ public static function getConstructorInvalidTmpData(): array [ 'tmpDoc' => 'documentation/invalid_version', 'exception' => InvalidSwaggerVersionException::class, - 'exceptionMessage' => "Unrecognized Swagger version '1.0'. Expected 2.0.", + 'exceptionMessage' => "Unrecognized Swagger version '1.0'. Expected 3.1.0.", ], [ 'tmpDoc' => 'documentation/invalid_format__array_parameter__no_items', diff --git a/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json b/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json index 45e9c178..6208cf33 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json +++ b/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt b/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt index 5566faea..ba9562d7 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt +++ b/tests/fixtures/AutoDocControllerTest/documentation__non_json.txt @@ -1,4 +1,4 @@ -swagger: "2.0" +openapi: "3.1.0", info: description: "This is a sample server Petstore server." version: "1.0.0" diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data.json b/tests/fixtures/AutoDocControllerTest/tmp_data.json index 4c350c0e..123261b0 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json index e812ac36..691f34b2 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -295,4 +295,4 @@ "email": "your@email.com" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json index c7e70b61..f64d1e89 100644 --- a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], @@ -107,4 +107,4 @@ "in": "header" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index 4c350c0e..123261b0 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index 3ac95f3c..fb742d07 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/PushDocumentationCommandTest/documentation.json b/tests/fixtures/PushDocumentationCommandTest/documentation.json index 37305656..43681dee 100644 --- a/tests/fixtures/PushDocumentationCommandTest/documentation.json +++ b/tests/fixtures/PushDocumentationCommandTest/documentation.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -14,4 +14,4 @@ "email": "your@email.com" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json index 06ee9318..96bd2ba4 100644 --- a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/RemoteDriverTest/tmp_data.json b/tests/fixtures/RemoteDriverTest/tmp_data.json index 4c350c0e..123261b0 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index 3ac95f3c..fb742d07 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/StorageDriverTest/tmp_data.json b/tests/fixtures/StorageDriverTest/tmp_data.json index 4c350c0e..123261b0 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data.json +++ b/tests/fixtures/StorageDriverTest/tmp_data.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json index 3ac95f3c..fb742d07 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"swagger":"2.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/documentation/array_response_header_with_items.json b/tests/fixtures/SwaggerServiceTest/documentation/array_response_header_with_items.json index 5fd100d8..d1619144 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/array_response_header_with_items.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/array_response_header_with_items.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -36,4 +36,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/formdata_request.json b/tests/fixtures/SwaggerServiceTest/documentation/formdata_request.json index 7f6cfd19..27556164 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/formdata_request.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/formdata_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -31,4 +31,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_parameter__no_items.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_parameter__no_items.json index 47675fb7..8aaa035b 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_parameter__no_items.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_parameter__no_items.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -24,4 +24,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_body__no_items.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_body__no_items.json index 6484e8ee..317995bd 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_body__no_items.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_body__no_items.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -18,4 +18,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_header__no_items.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_header__no_items.json index a871732e..24b89b27 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_header__no_items.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__array_response_header__no_items.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -23,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json index ba1ae7f1..f57cf541 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -58,4 +58,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json index 1ed3eaf3..708ab01a 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -47,4 +47,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json index 830673cb..4f9db1c8 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Swagger Petstore 2.0", @@ -298,4 +298,4 @@ "description": "Find out more about Swagger", "url": "http://swagger.io" } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json index 95e262ed..551168f6 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json index 9cc4454e..c9719eda 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -29,4 +29,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json index 925536ed..8fe343b9 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json index abe32b75..43968851 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -32,4 +32,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json index 337f47f2..7ec60097 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -28,4 +28,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_schema_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_schema_type.json index 9367a558..e6a25514 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_schema_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_schema_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -36,4 +36,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json index 823e860a..898b8247 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__path.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__path.json index 4d9d4845..3b112de2 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__path.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__path.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -15,4 +15,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__status_code.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__status_code.json index 4d4b9e71..33e3b908 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__status_code.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__status_code.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -15,4 +15,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json index 600f5a2d..cb643d73 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json index 79e73308..633ece3d 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json index d3ad3085..9a43d014 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Swagger Petstore 2.0" @@ -257,4 +257,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json index eadee203..7b75c8d1 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json index 779820c1..503720da 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Swagger Petstore 2.0" @@ -255,4 +255,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json index ea9c8614..3e97a63a 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json index 43c0565e..5013e4e4 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json index 45e9c178..6208cf33 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json index bcaf81ba..36c8f0a6 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__tag_name.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__tag_name.json index 9a194afc..d7328f8d 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__tag_name.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__tag_name.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Swagger Petstore 2.0" @@ -33,4 +33,4 @@ ], "paths": { } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json index 5f37a1f0..c33090f0 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json index 0062a2cf..2d404103 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -41,4 +41,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json index 3faa2df9..0c076c8b 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json index 891c1f79..1d990086 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -72,4 +72,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json index 165008a8..9eb55e44 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -45,4 +45,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json index c3cc60d9..40e0ed80 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -50,4 +50,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_placeholder_no_param.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_placeholder_no_param.json index 599678fb..87dcdc50 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_placeholder_no_param.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_placeholder_no_param.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -45,4 +45,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json index dd8a1642..199716f6 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json index e3ba0950..ddff4c52 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json index ee6f9676..5a0a740a 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_version.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_version.json index 773cb8ee..02ae65d9 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_version.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_version.json @@ -1,5 +1,5 @@ { - "swagger": "1.0", + "openapi": "1.0", "info": { "version": "1.0.0", "title": "Invalid API" @@ -15,4 +15,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json b/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json index 657c7c93..5f5af208 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 6b8b8578..6f8e292a 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -90,4 +90,4 @@ "email": "your@email.com" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json index 6b5dd6d6..9cd16cb9 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json index 1e0fcf36..1ccf7ed7 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json index 4b06ca3b..134971d8 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json index 8951d698..2a772dd5 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json index 3b64c970..cad7dd16 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json index 7a7babd2..d922b248 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json index 0d55c48d..e7aeee36 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json @@ -1,9 +1,9 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], "paths": [], "definitions": [], "info": [] -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json index 8e41bec9..4a086b09 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -21,4 +21,4 @@ "in": "header" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json index 12e360ac..27977a47 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -21,4 +21,4 @@ "in": "cookie" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json index 1e65a0d8..dd83b6f2 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -21,4 +21,4 @@ "in": "query" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json index 0bcfd57a..ebd2004a 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json index b6176e51..89aa69bb 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json index 7c618ae5..d9a08f02 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json index c50c5478..fa38daf6 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json index ffd79a9d..8d653ef5 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json index b725c943..d7f3dc22 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json index 1bd8547d..86e76e0e 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json index c2ade219..96f8f067 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json index 98acde99..085c36f6 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json index cbaa5e5a..68116ad3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json index 1c62bab3..9e75d7ac 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "/", "schemes": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json index 6182997d..d0dc8629 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -137,4 +137,4 @@ "email": "your@email.com" } } -} \ No newline at end of file +} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json index 943c46a1..5acb2bed 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json @@ -1,5 +1,5 @@ { - "swagger": "2.0", + "openapi": "3.1.0", "host": "localhost", "basePath": "\/", "schemes": [], @@ -159,4 +159,4 @@ "email": "your@email.com" } } -} \ No newline at end of file +} From c7d3fa4299dcc6ff0b3be82b03fb0f09449f5c54 Mon Sep 17 00:00:00 2001 From: Alexey Vardugin Date: Tue, 3 Sep 2024 08:36:06 +0600 Subject: [PATCH 2/8] feat: implemented requestBody --- src/Services/SwaggerService.php | 10 +++++----- tests/fixtures/LocalDriverTest/tmp_data.json | 8 +++++--- .../LocalDriverTest/tmp_data_non_formatted.json | 2 +- .../RemoteDriverTest/tmp_data_non_formatted.json | 2 +- .../tmp_data_create_user_request.json | 13 +++++++++++++ .../tmp_data_request_with_empty_data_and_info.json | 8 +++++--- .../tmp_data_request_with_empty_data_jwt.json | 8 +++++--- .../tmp_data_request_with_empty_data_laravel.json | 8 +++++--- .../tmp_data_request_with_empty_data_query.json | 8 +++++--- 9 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index e5442207..c0195fb7 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -29,7 +29,7 @@ class SwaggerService { use GetDependenciesTrait; - public const OPEN_API_VERSION = '3.1.0'; + public const string OPEN_API_VERSION = '3.1.0'; protected $driver; protected $openAPIValidator; @@ -139,9 +139,9 @@ protected function generateEmptyData(): array $data = [ 'openapi' => self::OPEN_API_VERSION, - 'host' => $this->getAppUrl(), - 'basePath' => $this->config['basePath'], - 'schemes' => $this->config['schemes'], + 'servers' => [ + ['url' => $this->config['basePath']], + ], 'paths' => [], 'definitions' => $this->config['definitions'], 'info' => $this->prepareInfo($this->config['info']) @@ -519,7 +519,7 @@ protected function savePostRequestParameters($actionName, $rules, array $attribu { if ($this->requestHasMoreProperties($actionName)) { if ($this->requestHasBody()) { - $this->item['parameters'][] = [ + $this->item['requestBody'][] = [ 'in' => 'body', 'name' => 'body', 'description' => '', diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index 123261b0..4753b3d3 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index fb742d07..fda87f80 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index fb742d07..8584c374 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 6f8e292a..81f6e396 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -23,6 +23,19 @@ } } ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "id": {"type": "string", "format": "uuid"}, + "profileImage": {"type": "string", "format": "binary"} + } + } + } + } + }, "responses": { "403": diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json index e7aeee36..6144b06c 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "/" + } + ], "paths": [], "definitions": [], "info": [] diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json index 4a086b09..8d37e459 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "/" + } + ], "paths": [], "definitions": [], "info": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json index 27977a47..fc3aae72 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "/" + } + ], "paths": [], "definitions": [], "info": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json index dd83b6f2..311088dd 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "/" + } + ], "paths": [], "definitions": [], "info": { From efdcb5981eb7c37074336dde44e9f90a3cde2fbd Mon Sep 17 00:00:00 2001 From: aizlee Date: Tue, 3 Sep 2024 16:32:40 +0600 Subject: [PATCH 3/8] feat: implemented requestBody --- src/Services/SwaggerService.php | 32 +++++++---- src/Validators/SwaggerSpecValidator.php | 46 +++++++++++++-- tests/SwaggerServiceTest.php | 2 +- ..._invalid_format__missing_field__paths.json | 8 ++- .../AutoDocControllerTest/tmp_data.json | 19 ++++--- .../tmp_data_with_additional_paths.json | 57 ++++++++++--------- .../tmp_data_search_roles_request.json | 20 +++++-- tests/fixtures/LocalDriverTest/tmp_data.json | 19 ++++--- .../tmp_data_non_formatted.json | 2 +- .../documentation.json | 8 ++- .../tmp_data_search_roles_request.json | 8 ++- tests/fixtures/RemoteDriverTest/tmp_data.json | 19 ++++--- .../tmp_data_non_formatted.json | 2 +- .../fixtures/StorageDriverTest/tmp_data.json | 19 ++++--- .../tmp_data_non_formatted.json | 2 +- .../invalid_format__body_and_form_params.json | 12 +++- ...valid_format__duplicate_header_params.json | 16 ++++-- ...nvalid_format__duplicate_operation_id.json | 47 +++++++-------- ...invalid_format__duplicate_path_params.json | 16 ++++-- ...d_format__duplicate_path_placeholders.json | 8 ++- .../invalid_format__duplicate_tag.json | 29 +++++++--- ...invalid_format__file_invalid_consumes.json | 8 ++- .../invalid_format__file_no_consumes.json | 8 ++- ...d_format__invalid_value__parameter_in.json | 8 ++- .../invalid_format__missing_external_ref.json | 8 ++- ...ormat__missing_field__definition_type.json | 8 ++- ...id_format__missing_field__header_type.json | 8 ++- ...d_format__missing_field__info_version.json | 8 ++- ...lid_format__missing_field__items_type.json | 8 ++- ...t__missing_field__operation_responses.json | 8 ++- ...d_format__missing_field__parameter_in.json | 8 ++- .../invalid_format__missing_field__paths.json | 8 ++- ...__missing_field__response_description.json | 8 ++- .../invalid_format__missing_local_ref.json | 8 ++- ...nvalid_format__missing_path_parameter.json | 12 +++- .../invalid_format__missing_ref_file.json | 8 ++- .../invalid_format__multiple_body_params.json | 16 ++++-- .../invalid_format__no_path_params.json | 8 ++- ...lid_format__path_param_no_placeholder.json | 12 +++- ...lid_format__security_definition__flow.json | 8 ++- ...valid_format__security_definition__in.json | 8 ++- ...lid_format__security_definition__type.json | 27 +++++---- .../documentation/with_definitions.json | 27 +++++---- .../tmp_data_create_user_request.json | 32 ++++------- ...data_get_route_parameters_description.json | 40 +++++++++---- .../tmp_data_get_user_request.json | 28 ++++++--- .../tmp_data_post_user_request.json | 27 +++++---- ..._post_user_request_with_object_params.json | 29 +++++----- .../tmp_data_put_user_request.json | 28 +++++---- ...user_request_with_early_generated_doc.json | 48 +++++++++------- ...data_request_with_empty_data_and_info.json | 2 +- .../tmp_data_request_with_empty_data_jwt.json | 2 +- ..._data_request_with_empty_data_laravel.json | 2 +- ...mp_data_request_with_empty_data_query.json | 2 +- ...tmp_data_search_roles_closure_request.json | 8 ++- .../tmp_data_search_roles_request.json | 20 +++++-- ...ch_roles_request_invalid_content_type.json | 20 +++++-- ...ata_search_roles_request_jwt_security.json | 20 +++++-- ...search_roles_request_laravel_security.json | 20 +++++-- .../tmp_data_search_roles_request_pdf.json | 20 +++++-- ..._data_search_roles_request_plain_text.json | 20 +++++-- ...a_search_roles_request_query_security.json | 20 +++++-- ...search_roles_request_with_annotations.json | 12 ++-- ...ata_search_roles_request_without_info.json | 8 ++- ...earch_roles_request_without_rule_type.json | 12 ++-- .../tmp_data_search_users_empty_request.json | 8 ++- .../tmp_data_search_users_request.json | 20 +++++-- 67 files changed, 683 insertions(+), 386 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index c0195fb7..a1ceaf03 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -46,7 +46,7 @@ class SwaggerService private $item; private $security; - protected $ruleToTypeMap = [ + protected array $ruleToTypeMap = [ 'array' => 'object', 'boolean' => 'boolean', 'date' => 'date', @@ -54,11 +54,11 @@ class SwaggerService 'integer' => 'integer', 'numeric' => 'double', 'string' => 'string', - 'int' => 'integer' + 'int' => 'integer', ]; protected $booleanAnnotations = [ - 'deprecated' + 'deprecated', ]; public function __construct(Container $container) @@ -140,7 +140,7 @@ protected function generateEmptyData(): array $data = [ 'openapi' => self::OPEN_API_VERSION, 'servers' => [ - ['url' => $this->config['basePath']], + ['url' => $this->getAppUrl() . $this->config['basePath']], ], 'paths' => [], 'definitions' => $this->config['definitions'], @@ -242,7 +242,9 @@ protected function getPathParams(): array 'name' => $key, 'description' => $this->generatePathDescription($key), 'required' => true, - 'type' => 'string' + "schema" => [ + 'type' => 'string' + ] ]; } @@ -504,7 +506,9 @@ protected function saveGetRequestParameters($rules, array $attributes, array $an 'in' => 'query', 'name' => $parameter, 'description' => $description, - 'type' => $this->getParameterType($validation) + 'schema' => [ + 'type' => $this->getParameterType($validation), + ], ]; if (in_array('required', $validation)) { $parameterDefinition['required'] = true; @@ -519,14 +523,18 @@ protected function savePostRequestParameters($actionName, $rules, array $attribu { if ($this->requestHasMoreProperties($actionName)) { if ($this->requestHasBody()) { - $this->item['requestBody'][] = [ - 'in' => 'body', - 'name' => 'body', + $type = $this->request->header('Content-Type') ?? 'application/json'; + + $this->item['requestBody'] = [ + 'content' => [ + $type => [ + 'schema' => [ + "\$ref" => "#/definitions/{$actionName}Object", + ], + ], + ], 'description' => '', 'required' => true, - 'schema' => [ - "\$ref" => "#/definitions/{$actionName}Object" - ] ]; } diff --git a/src/Validators/SwaggerSpecValidator.php b/src/Validators/SwaggerSpecValidator.php index 35b2f1d1..16df0f36 100644 --- a/src/Validators/SwaggerSpecValidator.php +++ b/src/Validators/SwaggerSpecValidator.php @@ -55,6 +55,7 @@ class SwaggerSpecValidator 'header' => ['type'], 'operation' => ['responses'], 'parameter' => ['in', 'name'], + 'requestBody' => ['content'], 'response' => ['description'], 'security_definition' => ['type'], 'tag' => ['name'], @@ -76,6 +77,7 @@ class SwaggerSpecValidator public const MIME_TYPE_MULTIPART_FORM_DATA = 'multipart/form-data'; public const MIME_TYPE_APPLICATION_URLENCODED = 'application/x-www-form-urlencoded'; + public const MIME_TYPE_APPLICATION_JSON = 'application/json'; protected $doc; @@ -128,6 +130,10 @@ protected function validatePaths(): void $this->validateParameters($operation, $path, $operationId); + if (!empty($operation['requestBody'])) { + $this->validateRequestBody($operation, $path, $operationId); + } + foreach ($operation['responses'] as $statusCode => $response) { $this->validateResponse($response, $statusCode, $operationId); } @@ -220,8 +226,8 @@ protected function validateParameters(array $operation, string $path, string $op $this->validateParameterType($param, $operation, $paramId, $operationId); - if (!empty($param['items'])) { - $this->validateItems($param['items'], "{$paramId}.items"); + if (!empty($param['schema']['items'])) { + $this->validateItems($param['schema']['items'], "{$paramId}.schema.items"); } } @@ -230,6 +236,38 @@ protected function validateParameters(array $operation, string $path, string $op $this->validateBodyParameters($parameters, $operationId); } + protected function validateRequestBody(array $operation, string $path, string $operationId): void + { + $requestBody = Arr::get($operation, 'requestBody', []); + + $this->validateFieldsPresent(self::REQUIRED_FIELDS['requestBody'], "{$operationId}.requestBody"); + + $this->validateRequestBodyContent($requestBody['content'], $operationId); + } + + protected function validateRequestBodyContent(array $content, string $operationId): void + { + $allowedContentType = false; + + $types = [ + self::MIME_TYPE_APPLICATION_URLENCODED, + self::MIME_TYPE_MULTIPART_FORM_DATA, + self::MIME_TYPE_APPLICATION_JSON, + ]; + + foreach ($types as $type) { + if (!empty($content[$type])) { + $allowedContentType = true; + } + } + + if (!$allowedContentType) { + throw new InvalidSwaggerSpecException( + "Operation '{$operationId}' has body parameters. Only one or the other is allowed." + ); + } + } + protected function validateType(array $schema, array $validTypes, string $schemaId): void { $schemaType = Arr::get($schema, 'type'); @@ -313,12 +351,12 @@ protected function validateParameterType(array $param, array $operation, string case 'formData': $this->validateFormDataConsumes($operation, $operationId); - $requiredFields = ['type']; + $requiredFields = ['schema']; $validTypes = array_merge(self::PRIMITIVE_TYPES, ['file']); break; default: - $requiredFields = ['type']; + $requiredFields = ['schema']; $validTypes = self::PRIMITIVE_TYPES; } diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 00398d02..9355fb99 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -229,7 +229,7 @@ public static function getConstructorInvalidTmpData(): array [ 'tmpDoc' => 'documentation/invalid_format__missing_field__items_type', 'exception' => MissingFieldException::class, - 'exceptionMessage' => "Validation failed. 'paths./pet/findByStatus.get.parameters.0.items' " + 'exceptionMessage' => "Validation failed. 'paths./pet/findByStatus.get.parameters.0.schema.items' " . "should have required fields: type.", ], [ diff --git a/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json b/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json index 6208cf33..64f56b7f 100644 --- a/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json +++ b/tests/fixtures/AutoDocControllerTest/documentation__invalid_format__missing_field__paths.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "definitions": { "authloginObject": { "type": "object", diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data.json b/tests/fixtures/AutoDocControllerTest/tmp_data.json index 123261b0..fc93a565 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data.json @@ -15,17 +15,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json index 691f34b2..6c42e70c 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json @@ -15,17 +15,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", @@ -93,17 +94,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", @@ -173,17 +175,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/apiusersObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/apiusersObject" - } + "description": "" } - ], + }, "responses": { "403": { "description": "Forbidden", diff --git a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json index f64d1e89..2bd72f47 100644 --- a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index 4753b3d3..8ca274e5 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -17,17 +17,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index fda87f80..bafbb332 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/PushDocumentationCommandTest/documentation.json b/tests/fixtures/PushDocumentationCommandTest/documentation.json index 43681dee..e31c3ee5 100644 --- a/tests/fixtures/PushDocumentationCommandTest/documentation.json +++ b/tests/fixtures/PushDocumentationCommandTest/documentation.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": [], "definitions": [], "info": { diff --git a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json index 96bd2ba4..bddb4e99 100644 --- a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { diff --git a/tests/fixtures/RemoteDriverTest/tmp_data.json b/tests/fixtures/RemoteDriverTest/tmp_data.json index 123261b0..fc93a565 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data.json @@ -15,17 +15,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index 8584c374..1df844f4 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/StorageDriverTest/tmp_data.json b/tests/fixtures/StorageDriverTest/tmp_data.json index 123261b0..fc93a565 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data.json +++ b/tests/fixtures/StorageDriverTest/tmp_data.json @@ -15,17 +15,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/authloginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/authloginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json index fb742d07..1df844f4 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[{"in":"body","name":"body","description":"","required":true,"schema":{"$ref":"#\/definitions\/authloginObject"}}],"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json index f57cf541..47f3b7a8 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__body_and_form_params.json @@ -12,7 +12,9 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "username", @@ -35,7 +37,9 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "foo", @@ -47,7 +51,9 @@ { "name": "bar", "in": "formData", - "type": "number" + "schema": { + "type": "number" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json index 708ab01a..db93a61f 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_header_params.json @@ -12,18 +12,24 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "foo", "in": "header", - "type": "string", + "schema": { + "type": "string" + }, "required": false }, { "name": "username", "in": "header", - "type": "string" + "schema": { + "type": "string" + } }, { "name": "username", @@ -35,7 +41,9 @@ { "name": "foo", "in": "header", - "type": "number", + "schema": { + "type": "number" + }, "required": true } ], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json index 4f9db1c8..a8feba3e 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_operation_id.json @@ -11,11 +11,10 @@ "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, - "host": "petstore.swagger.io", - "basePath": "/v2", - "schemes": [ - "https", - "http" + "servers": [ + { + "url": "https://petstore.swagger.io/v2" + } ], "paths": { "/pet": { @@ -34,17 +33,18 @@ "application/xml", "application/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "Pet object that needs to be added to the store", - "required": true, - "schema": { - "$ref": "#/definitions/Pet" + "parameters": [], + "requestBody": { + "required": true, + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/Pet" + } } } - ], + }, "responses": { "405": { "description": "Invalid input" @@ -74,17 +74,18 @@ "application/xml", "application/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "Pet object that needs to be added to the store", - "required": true, - "schema": { - "$ref": "#/definitions/Pet" + "parameters": [], + "requestBody": { + "required": true, + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/Pet" + } } } - ], + }, "responses": { "400": { "description": "Invalid ID supplied" diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json index 551168f6..2977d7a1 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_params.json @@ -12,18 +12,24 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "bar", "in": "header", - "type": "string", + "schema": { + "type": "string" + }, "required": false }, { "name": "username", "in": "header", - "type": "string" + "schema": { + "type": "string" + } }, { "name": "username", @@ -35,7 +41,9 @@ { "name": "username", "in": "path", - "type": "number", + "schema": { + "type": "number" + }, "required": true } ], diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json index c9719eda..24943790 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_path_placeholders.json @@ -12,13 +12,17 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "img_id", "in": "path", "required": true, - "type": "number" + "schema": { + "type": "number" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json index 8fe343b9..b105cda8 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__duplicate_tag.json @@ -30,27 +30,42 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "bar", "in": "header", - "type": "string", + "schema": { + "type": "string" + }, "required": false }, { "name": "username", "in": "header", - "type": "string" - }, - { - "name": "username", - "in": "body", "schema": { "type": "string" } } ], + "requestBody": { + "required": true, + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "username": { + "type": "string" + } + } + } + } + } + }, "responses": { "default": { "description": "hello world" diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json index 43968851..80a79ba1 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_invalid_consumes.json @@ -11,13 +11,17 @@ { "name": "username", "in": "path", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "name": "image", "in": "formData", - "type": "file" + "schema": { + "type": "file" + } } ], "consumes": [ diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json index 7ec60097..160435ed 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__file_no_consumes.json @@ -11,13 +11,17 @@ { "name": "username", "in": "path", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "name": "image", "in": "formData", - "type": "file" + "schema": { + "type": "file" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json index 898b8247..d76d88fb 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__invalid_value__parameter_in.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json index cb643d73..5d28d75e 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_external_ref.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json index 633ece3d..73b4f514 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json index 9a43d014..c3d562a8 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__header_type.json @@ -51,14 +51,18 @@ "in": "query", "description": "The user name for login", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "password", "in": "query", "description": "The password for login in clear text", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json index 7b75c8d1..95810ce2 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__info_version.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { }, "info": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json index 503720da..798f5d6a 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__items_type.json @@ -51,9 +51,11 @@ "in": "query", "description": "Status values that need to be considered for filter", "required": true, - "type": "array", - "items": { - "default": "available" + "schema": { + "type": "array", + "items": { + "collectionFormat": "multi" + } }, "collectionFormat": "multi" } diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json index 3e97a63a..842e35ca 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__operation_responses.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json index 5013e4e4..18435dbc 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__parameter_in.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json index 6208cf33..64f56b7f 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__paths.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "definitions": { "authloginObject": { "type": "object", diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json index 36c8f0a6..b0ca837c 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__response_description.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json index c33090f0..be9ba69d 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_local_ref.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json index 2d404103..a69ed113 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_path_parameter.json @@ -12,18 +12,24 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "bar", "in": "header", - "type": "string", + "schema": { + "type": "string" + }, "required": false }, { "name": "username", "in": "header", - "type": "string" + "schema": { + "type": "string" + } }, { "name": "username", diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json index 0c076c8b..69c306ae 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_ref_file.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json index 1d990086..f053e931 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__multiple_body_params.json @@ -12,12 +12,16 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "bar", "in": "header", - "type": "number", + "schema": { + "type": "number" + }, "required": true }, { @@ -48,12 +52,16 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "bar", "in": "header", - "type": "number", + "schema": { + "type": "number" + }, "required": true }, { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json index 9eb55e44..4b887537 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__no_path_params.json @@ -12,7 +12,9 @@ "name": "username", "in": "header", "required": true, - "type": "number" + "schema": { + "type": "number" + } }, { "name": "foo", @@ -34,7 +36,9 @@ "name": "username", "in": "header", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json index 40e0ed80..18ab9121 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__path_param_no_placeholder.json @@ -12,7 +12,9 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "foo", @@ -34,12 +36,16 @@ "name": "username", "in": "path", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "foo", "in": "path", - "type": "number" + "schema": { + "type": "number" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json index 199716f6..18a3e102 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__flow.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json index ddff4c52..d2adb33b 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__in.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": { diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json index 5a0a740a..c2d36675 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__security_definition__type.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": { @@ -11,17 +13,18 @@ "tags": ["api"], "consumes": ["application\/x-www-form-urlencoded"], "produces": ["application\/json"], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/apiusersObject" + } + }, "required": true, - "schema": { - "$ref": "#/definitions/apiusersObject" - } + "description": "" } - ], + }, "responses": { "403": diff --git a/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json b/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json index 5f5af208..3af06bb8 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/with_definitions.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/auth\/login": { "post": { @@ -15,17 +17,18 @@ "produces": [ "application\/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/loginObject" + } + }, "required": true, - "schema": { - "$ref": "#\/definitions\/loginObject" - } + "description": "" } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 81f6e396..63641470 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": @@ -12,29 +14,17 @@ "tags": ["api"], "consumes": ["application\/x-www-form-urlencoded"], "produces": ["application\/json"], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", - "required": true, - "schema": { - "$ref": "#/definitions/apiusersObject" - } - } - ], + "parameters": [], "requestBody": { "content": { - "multipart/form-data": { + "application/x-www-form-urlencoded": { "schema": { - "type": "object", - "properties": { - "id": {"type": "string", "format": "uuid"}, - "profileImage": {"type": "string", "format": "binary"} - } + "$ref": "#/definitions/apiusersObject" } } - } + }, + "required": true, + "description": "" }, "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json index 9cd16cb9..50c79517 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/v{versions}/users/{id}/{some_string}/{uuid}/{withoutConditional}": { "get": { @@ -19,54 +21,70 @@ "name": "versions", "description": "in: 0.2,1,3.1", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "path", "name": "id", "description": "regexp: [0-9]+", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "path", "name": "some_string", "description": "in: first,second,last", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "path", "name": "uuid", "description": "regexp: [\\da-fA-F]{8}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{12}", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "path", "name": "withoutConditional", "description": "", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "query", "name": "query", "description": "string, required", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", "description": "test_rule_without_to_string", - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json index 1ccf7ed7..578e4eea 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/{id}/assign-role/{role-id}": { "get": { @@ -19,32 +21,42 @@ "name": "id", "description": "", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "path", "name": "role-id", "description": "", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json index 134971d8..3129a398 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users": { "post": { @@ -15,17 +17,18 @@ "produces": [ "application/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", - "required": true, - "schema": { - "$ref": "#/definitions/usersObject" + "parameters": [], + "requestBody": { + "required": true, + "description": "", + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/definitions/usersObject" + } } } - ], + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json index 2a772dd5..2b9f7451 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users": { "post": { @@ -13,17 +15,18 @@ "produces": [ "application/json" ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "", - "required": true, - "schema": { - "$ref": "#/definitions/usersObject" + "parameters": [], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/definitions/usersObject" + } } - } - ], + }, + "required": true, + "description": "" + }, "responses": { "200": { "description": "Operation successfully done", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json index cad7dd16..770185ce 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/{id}": { "put": { @@ -19,18 +21,22 @@ "name": "id", "description": "", "required": true, - "type": "string" - }, - { - "in": "body", - "name": "body", - "description": "", - "required": true, "schema": { - "$ref": "#/definitions/users{id}Object" + "type": "string" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/users{id}Object" + } + } + }, + "required": true, + "description": "" + }, "responses": { "204": { "description": "Operation successfully done", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json index d922b248..f2453e2a 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/{id}": { "put": { @@ -19,18 +21,22 @@ "name": "id", "description": "", "required": true, - "type": "string" - }, - { - "in": "body", - "name": "body", - "description": "", - "required": true, "schema": { - "$ref": "#/definitions/users{id}Object" + "type": "string" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/users{id}Object" + } + } + }, + "required": true, + "description": "" + }, "responses": { "204": { "description": "Operation successfully done", @@ -87,18 +93,22 @@ "name": "id", "description": "", "required": true, - "type": "string" - }, - { - "in": "body", - "name": "body", - "description": "", - "required": true, "schema": { - "$ref": "#/definitions/users{id}Object" + "type": "string" } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/definitions/users{id}Object" + } + } + }, + "required": true, + "description": "" + }, "responses": { "204": { "description": "Operation successfully done", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json index 6144b06c..9eae2d00 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "servers": [ { - "url": "/" + "url": "localhost/" } ], "paths": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json index 8d37e459..c5b613b2 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "servers": [ { - "url": "/" + "url": "localhost/" } ], "paths": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json index fc3aae72..8b8d6891 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "servers": [ { - "url": "/" + "url": "localhost/" } ], "paths": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json index 311088dd..f29a0984 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "servers": [ { - "url": "/" + "url": "localhost/" } ], "paths": [], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json index ebd2004a..c1636a5c 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json index 89aa69bb..c589d365 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json index d9a08f02..f4220b53 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json index fa38daf6..8ece231e 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json index 8d653ef5..921a40a3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json index d7f3dc22..c271ac79 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json index 86e76e0e..a7e53842 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json index 96f8f067..74b53a22 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "localhost/" + } + ], "paths": { "/users/roles": { "get": { @@ -20,19 +22,25 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json index 085c36f6..abda610e 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,7 +22,9 @@ "in": "query", "name": "query", "description": "string, required", - "type": "string", + "schema": { + "type": "string" + }, "required": true } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json index 68116ad3..768a64ec 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json index 9e75d7ac..7d6fbbf7 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "/users/roles": { "get": { @@ -20,7 +22,9 @@ "in": "query", "name": "query", "description": "required", - "type": "string", + "schema": { + "type": "string" + }, "required": true } ], diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json index d0dc8629..3c0c67d4 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json index 5acb2bed..cd42f004 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json @@ -1,8 +1,10 @@ { "openapi": "3.1.0", - "host": "localhost", - "basePath": "\/", - "schemes": [], + "servers": [ + { + "url": "http:\/\/localhost" + } + ], "paths": { "\/api\/users": @@ -17,18 +19,24 @@ "name": "query", "description": "string, required", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "in": "query", "name": "user_id", "description": "integer, with_to_array_rule_string_name", - "type": "integer" + "schema": { + "type": "integer" + } }, { "in": "query", "name": "is_email_enabled", - "type": "string", + "schema": { + "type": "string" + }, "description": "test_rule_without_to_string" } ], From b9a598362413abf257eb0fab9a9f54fd61a1123b Mon Sep 17 00:00:00 2001 From: aizlee Date: Mon, 16 Sep 2024 11:43:10 +0600 Subject: [PATCH 4/8] feat: implemented new responses format --- src/Services/SwaggerService.php | 28 ++- .../AutoDocControllerTest/tmp_data.json | 87 ++++--- .../tmp_data_with_additional_paths.json | 228 ++++++++++-------- .../tmp_data_search_roles_request.json | 49 ++-- tests/fixtures/LocalDriverTest/tmp_data.json | 87 ++++--- .../tmp_data_non_formatted.json | 2 +- .../tmp_data_search_roles_request.json | 47 ++-- tests/fixtures/RemoteDriverTest/tmp_data.json | 87 ++++--- .../tmp_data_non_formatted.json | 2 +- .../fixtures/StorageDriverTest/tmp_data.json | 87 ++++--- .../tmp_data_non_formatted.json | 2 +- .../tmp_data_create_user_request.json | 15 +- ...data_get_route_parameters_description.json | 29 ++- .../tmp_data_get_user_request.json | 29 ++- .../tmp_data_post_user_request.json | 49 ++-- ..._post_user_request_with_object_params.json | 49 ++-- .../tmp_data_put_user_request.json | 47 ++-- ...user_request_with_early_generated_doc.json | 58 +++-- ...tmp_data_search_roles_closure_request.json | 49 ++-- .../tmp_data_search_roles_request.json | 65 ++--- ...ata_search_roles_request_jwt_security.json | 49 ++-- ...search_roles_request_laravel_security.json | 47 ++-- .../tmp_data_search_roles_request_pdf.json | 29 ++- ..._data_search_roles_request_plain_text.json | 13 +- ...a_search_roles_request_query_security.json | 49 ++-- ...search_roles_request_with_annotations.json | 47 ++-- ...earch_roles_request_without_rule_type.json | 47 ++-- .../tmp_data_search_users_empty_request.json | 109 +++++---- .../tmp_data_search_users_request.json | 109 +++++---- 29 files changed, 899 insertions(+), 696 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index a1ceaf03..038aad6b 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -397,7 +397,7 @@ protected function parseResponse($response) $this->saveResponseSchema($content, $definition); if (is_array($this->item['responses'][$code])) { - $this->item['responses'][$code]['schema']['$ref'] = "#/definitions/{$definition}"; + $this->item['responses'][$code]['content'][$produce]['$ref'] = "#/definitions/{$definition}"; } } @@ -420,17 +420,23 @@ protected function saveExample($code, $content, $produce) protected function makeResponseExample($content, $mimeType, $description = ''): array { - $responseExample = ['description' => $description]; + $example = match ($mimeType) { + 'application/json' => json_decode($content, true), + 'application/pdf' => base64_encode($content), + default => $content, + }; - if ($mimeType === 'application/json') { - $responseExample['schema'] = ['example' => json_decode($content, true)]; - } elseif ($mimeType === 'application/pdf') { - $responseExample['schema'] = ['example' => base64_encode($content)]; - } else { - $responseExample['examples']['example'] = $content; - } - - return $responseExample; + return [ + 'description' => $description, + 'content' => [ + $mimeType => [ + 'schema' => [ + 'type' => 'object', + 'example' => $example, + ], + ], + ], + ]; } protected function saveParameters($request, array $annotations) diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data.json b/tests/fixtures/AutoDocControllerTest/tmp_data.json index fc93a565..ad92aa35 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data.json @@ -30,52 +30,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 + }, + "type": "object" + } } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json index 6c42e70c..4ed1c387 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json @@ -30,52 +30,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 + }, + "type": "object" + } } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } @@ -109,52 +124,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 } }, - "ttl": 60, - "refresh_ttl": 20160 + "type": "object" } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } @@ -190,9 +220,14 @@ "responses": { "403": { "description": "Forbidden", - "schema": { - "example": { - "message": "This action is unauthorized." + "content": { + "application/json": { + "schema": { + "example": { + "message": "This action is unauthorized." + }, + "type": "object" + } } } } @@ -215,33 +250,38 @@ "responses": { "200": { "description": "OK", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } ] - } - ] + }, + "type": "object" + } } } }, diff --git a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json index 2bd72f47..41ca0b7a 100644 --- a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json @@ -47,34 +47,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index 8ca274e5..b24f158e 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -32,52 +32,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 + }, + "type": "object" + } } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index bafbb332..e46fd75c 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json index bddb4e99..ed6b51ac 100644 --- a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json @@ -29,33 +29,38 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ] + } } } }, diff --git a/tests/fixtures/RemoteDriverTest/tmp_data.json b/tests/fixtures/RemoteDriverTest/tmp_data.json index fc93a565..ad92aa35 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data.json @@ -30,52 +30,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 + }, + "type": "object" + } } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index 1df844f4..89ce7104 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/StorageDriverTest/tmp_data.json b/tests/fixtures/StorageDriverTest/tmp_data.json index fc93a565..ad92aa35 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data.json +++ b/tests/fixtures/StorageDriverTest/tmp_data.json @@ -30,52 +30,67 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "token": "some_token", - "user": { - "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "content": { + "application/json": { + "schema": { + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { + "id": 2, + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } + }, + "ttl": 60, + "refresh_ttl": 20160 + }, + "type": "object" + } } } }, "401": { "description": "Unauthorized", - "schema": { - "example": { - "error": "You have entered an incorrect credentials." + "content": { + "application/json": { + "schema": { + "example": { + "error": "You have entered an incorrect credentials." + }, + "type": "object" + } } } }, "400": { "description": "Bad Request", - "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + "content": { + "application/json": { + "schema": { + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." + }, + "type": "object" + } } } } diff --git a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json index 1df844f4..89ce7104 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}},"401":{"description":"Unauthorized","schema":{"example":{"error":"You have entered an incorrect credentials."}}},"400":{"description":"Bad Request","schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 63641470..3a9abf04 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -31,12 +31,15 @@ "403": { "description": "Forbidden", - "schema": - { - "$ref": "#/definitions/postApiusers403ResponseObject", - "example": - { - "message": "This action is unauthorized." + "content": { + "application/json": { + "$ref": "#/definitions/postApiusers403ResponseObject", + "schema": { + "type": "object", + "example": { + "message": "This action is unauthorized." + } + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json index 50c79517..dffe188f 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json @@ -90,18 +90,23 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "id": 2, - "name": "first_client", - "likes_count": 23, - "role": { - "id": 2, - "name": "client" - }, - "type": "reader" - }, - "$ref": "#/definitions/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject" + "content": { + "application/json": { + "$ref": "#/definitions/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject", + "schema": { + "example": { + "id": 2, + "name": "first_client", + "likes_count": 23, + "role": { + "id": 2, + "name": "client" + }, + "type": "reader" + }, + "type": "object" + } + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json index 578e4eea..9249d2e3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json @@ -63,18 +63,23 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": { - "id": 2, - "name": "first_client", - "likes_count": 23, - "role": { - "id": 2, - "name": "client" - }, - "type": "reader" - }, - "$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject" + "content": { + "application/json": { + "$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject", + "schema": { + "type": "object", + "example": { + "id": 2, + "name": "first_client", + "likes_count": 23, + "role": { + "id": 2, + "name": "client" + }, + "type": "reader" + } + } + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json index 3129a398..59cb5e02 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json @@ -32,34 +32,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/postUsers200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/postUsers200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json index 2b9f7451..4a00aca3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json @@ -30,34 +30,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/postUsers200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/postUsers200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json index 770185ce..26717d07 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json @@ -40,33 +40,38 @@ "responses": { "204": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ] + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json index f2453e2a..7f2bbdaa 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json @@ -40,33 +40,38 @@ "responses": { "204": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ] + } } } }, @@ -112,9 +117,14 @@ "responses": { "204": { "description": "Operation successfully done", - "schema": { - "example": [], - "$ref": "#/definitions/patchUsers{id}204ResponseObject" + "content": { + "application/json": { + "$ref": "#/definitions/patchUsers{id}204ResponseObject", + "schema": { + "example": [], + "type": "object" + } + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json index c1636a5c..f7da9820 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json @@ -19,34 +19,39 @@ "responses": { "200": { "description": "OK", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json index c589d365..584e56c8 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json @@ -47,34 +47,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } ] } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, @@ -87,17 +92,17 @@ }, "definitions": { "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } - } }, "info": { "description": "This is automatically collected documentation", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json index 8ece231e..dba6aa88 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json @@ -47,34 +47,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json index 921a40a3..94039afe 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json @@ -47,34 +47,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } ] } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json index c271ac79..f8444ca9 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json @@ -47,9 +47,14 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": "WwogICAgewogICAgICAgICJpZCI6IDEsCiAgICAgICAgIm5hbWUiOiAiYWRtaW4iLAogICAgICAgICJ1c2VycyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImlkIjogMSwKICAgICAgICAgICAgICAgICJuYW1lIjogImFkbWluIgogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAiaWQiOiAyLAogICAgICAgICJuYW1lIjogImNsaWVudCIsCiAgICAgICAgInVzZXJzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAyLAogICAgICAgICAgICAgICAgIm5hbWUiOiAiZmlyc3RfY2xpZW50IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAzLAogICAgICAgICAgICAgICAgIm5hbWUiOiAic2Vjb25kX2NsaWVudCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==", - "$ref": "#/definitions/getUsersroles200ResponseObject" + "content": { + "application/pdf": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": "WwogICAgewogICAgICAgICJpZCI6IDEsCiAgICAgICAgIm5hbWUiOiAiYWRtaW4iLAogICAgICAgICJ1c2VycyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImlkIjogMSwKICAgICAgICAgICAgICAgICJuYW1lIjogImFkbWluIgogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAiaWQiOiAyLAogICAgICAgICJuYW1lIjogImNsaWVudCIsCiAgICAgICAgInVzZXJzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAyLAogICAgICAgICAgICAgICAgIm5hbWUiOiAiZmlyc3RfY2xpZW50IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAzLAogICAgICAgICAgICAgICAgIm5hbWUiOiAic2Vjb25kX2NsaWVudCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==" + } + } } } }, @@ -62,17 +67,17 @@ }, "definitions": { "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } - } }, "info": { "description": "This is automatically collected documentation", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json index a7e53842..93565547 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json @@ -47,11 +47,14 @@ "responses": { "200": { "description": "Operation successfully done", - "examples": { - "example": "[\n {\n \"id\": 1,\n \"name\": \"admin\",\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"admin\"\n }\n ]\n }\n]" - }, - "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject" + "content": { + "text/plain": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": "[\n {\n \"id\": 1,\n \"name\": \"admin\",\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"admin\"\n }\n ]\n }\n]" + } + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json index 74b53a22..fd880261 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json @@ -47,34 +47,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } - ] + ], + "type": "object" } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json index abda610e..83e416e0 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json @@ -31,34 +31,39 @@ "responses": { "200": { "description": "The operation was completed successfully", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } ] } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json index 7d6fbbf7..114f8ec0 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json @@ -31,34 +31,39 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ + "content": { + "application/json": { + "$ref": "#/definitions/getUsersroles200ResponseObject", + "schema": { + "type": "object", + "example": [ { "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] }, { - "id": 3, - "name": "second_client" + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] } ] } - ], - "$ref": "#/definitions/getUsersroles200ResponseObject" + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json index 3c0c67d4..5ea1085e 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json @@ -19,60 +19,63 @@ "200": { "description": "OK", - "schema": - { - "example": - { - "current_page": 1, - "data": [ - { - "id": 1, - "first_name": "Billy", - "last_name": "Coleman", - "email": "billy.coleman@example.com", - "created_at": null, - "updated_at": null, - "role_id": 1, - "date_of_birth": "1986-05-20", - "phone": "+79535482530", - "position": "admin", - "starts_on": "2022-04-16 00:00:00", - "hr_id": null, - "manager_id": null, - "lead_id": null, - "avatar_id": null, - "deleted_at": null, - "company_id": 1 - } - ], - "first_page_url": "http:\/\/localhost\/api\/users?page=1", - "from": 1, - "last_page": 1, - "last_page_url": "http:\/\/localhost\/api\/users?page=1", - "links": [ - { - "url": null, - "label": "« Previous", - "active": false + "content": { + "application\/json": { + "$ref": "#/definitions/getApiusers200ResponseObject", + "schema": { + "example": { + "current_page": 1, + "data": [ + { + "id": 1, + "first_name": "Billy", + "last_name": "Coleman", + "email": "billy.coleman@example.com", + "created_at": null, + "updated_at": null, + "role_id": 1, + "date_of_birth": "1986-05-20", + "phone": "+79535482530", + "position": "admin", + "starts_on": "2022-04-16 00:00:00", + "hr_id": null, + "manager_id": null, + "lead_id": null, + "avatar_id": null, + "deleted_at": null, + "company_id": 1 + } + ], + "first_page_url": "http:\/\/localhost\/api\/users?page=1", + "from": 1, + "last_page": 1, + "last_page_url": "http:\/\/localhost\/api\/users?page=1", + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/localhost\/api\/users?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + }], + "next_page_url": null, + "path": "http:\/\/localhost\/api\/users", + "per_page": 20, + "prev_page_url": null, + "to": 1, + "total": 1 }, - { - "url": "http:\/\/localhost\/api\/users?page=1", - "label": "1", - "active": true - }, - { - "url": null, - "label": "Next »", - "active": false - }], - "next_page_url": null, - "path": "http:\/\/localhost\/api\/users", - "per_page": 20, - "prev_page_url": null, - "to": 1, - "total": 1 - }, - "$ref": "#/definitions/getApiusers200ResponseObject" + "type": "object" + } + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json index cd42f004..55e7b068 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json @@ -45,60 +45,63 @@ "200": { "description": "Operation successfully done", - "schema": - { - "example": - { - "current_page": 1, - "data": [ - { - "id": 1, - "first_name": "Billy", - "last_name": "Coleman", - "email": "billy.coleman@example.com", - "created_at": null, - "updated_at": null, - "role_id": 1, - "date_of_birth": "1986-05-20", - "phone": "+79535482530", - "position": "admin", - "starts_on": "2022-04-16 00:00:00", - "hr_id": null, - "manager_id": null, - "lead_id": null, - "avatar_id": null, - "deleted_at": null, - "company_id": 1 - } - ], - "first_page_url": "http:\/\/localhost\/api\/users?page=1", - "from": 1, - "last_page": 1, - "last_page_url": "http:\/\/localhost\/api\/users?page=1", - "links": [ - { - "url": null, - "label": "« Previous", - "active": false + "content": { + "application\/json": { + "$ref": "#/definitions/getApiusers200ResponseObject", + "schema": { + "example": { + "current_page": 1, + "data": [ + { + "id": 1, + "first_name": "Billy", + "last_name": "Coleman", + "email": "billy.coleman@example.com", + "created_at": null, + "updated_at": null, + "role_id": 1, + "date_of_birth": "1986-05-20", + "phone": "+79535482530", + "position": "admin", + "starts_on": "2022-04-16 00:00:00", + "hr_id": null, + "manager_id": null, + "lead_id": null, + "avatar_id": null, + "deleted_at": null, + "company_id": 1 + } + ], + "first_page_url": "http:\/\/localhost\/api\/users?page=1", + "from": 1, + "last_page": 1, + "last_page_url": "http:\/\/localhost\/api\/users?page=1", + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/localhost\/api\/users?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + }], + "next_page_url": null, + "path": "http:\/\/localhost\/api\/users", + "per_page": 20, + "prev_page_url": null, + "to": 1, + "total": 1 }, - { - "url": "http:\/\/localhost\/api\/users?page=1", - "label": "1", - "active": true - }, - { - "url": null, - "label": "Next »", - "active": false - }], - "next_page_url": null, - "path": "http:\/\/localhost\/api\/users", - "per_page": 20, - "prev_page_url": null, - "to": 1, - "total": 1 - }, - "$ref": "#/definitions/getApiusers200ResponseObject" + "type": "object" + } + } } } }, From 4a8e6f90d6fd1db102fbc59b1292b3854f520c70 Mon Sep 17 00:00:00 2001 From: aizlee Date: Mon, 16 Sep 2024 15:00:44 +0600 Subject: [PATCH 5/8] refactor: references and examples --- src/Services/SwaggerService.php | 4 +- .../AutoDocControllerTest/tmp_data.json | 70 ++++++------ .../tmp_data_with_additional_paths.json | 70 ++++++------ .../tmp_data_search_roles_request.json | 56 +++++----- tests/fixtures/LocalDriverTest/tmp_data.json | 70 ++++++------ .../tmp_data_non_formatted.json | 2 +- .../tmp_data_search_roles_request.json | 54 +++++----- tests/fixtures/RemoteDriverTest/tmp_data.json | 70 ++++++------ .../tmp_data_non_formatted.json | 2 +- .../fixtures/StorageDriverTest/tmp_data.json | 70 ++++++------ .../tmp_data_non_formatted.json | 2 +- .../tmp_data_create_user_request.json | 10 +- ...data_get_route_parameters_description.json | 20 ++-- .../tmp_data_get_user_request.json | 22 ++-- .../tmp_data_post_user_request.json | 57 +++++----- ..._post_user_request_with_object_params.json | 57 +++++----- .../tmp_data_put_user_request.json | 54 +++++----- ...user_request_with_early_generated_doc.json | 60 +++++------ ...tmp_data_search_roles_closure_request.json | 56 +++++----- .../tmp_data_search_roles_request.json | 58 +++++----- ...ata_search_roles_request_jwt_security.json | 56 +++++----- ...search_roles_request_laravel_security.json | 58 +++++----- .../tmp_data_search_roles_request_pdf.json | 8 +- ..._data_search_roles_request_plain_text.json | 8 +- ...a_search_roles_request_query_security.json | 56 +++++----- ...search_roles_request_with_annotations.json | 58 +++++----- ...ata_search_roles_request_without_info.json | 57 +++++----- ...earch_roles_request_without_rule_type.json | 58 +++++----- .../tmp_data_search_users_empty_request.json | 102 +++++++++--------- .../tmp_data_search_users_request.json | 102 +++++++++--------- 30 files changed, 715 insertions(+), 712 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 038aad6b..a186cfa7 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -397,7 +397,7 @@ protected function parseResponse($response) $this->saveResponseSchema($content, $definition); if (is_array($this->item['responses'][$code])) { - $this->item['responses'][$code]['content'][$produce]['$ref'] = "#/definitions/{$definition}"; + $this->item['responses'][$code]['content'][$produce]['schema']['$ref'] = "#/definitions/{$definition}"; } } @@ -432,8 +432,8 @@ protected function makeResponseExample($content, $mimeType, $description = ''): $mimeType => [ 'schema' => [ 'type' => 'object', - 'example' => $example, ], + 'example' => $example, ], ], ]; diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data.json b/tests/fixtures/AutoDocControllerTest/tmp_data.json index ad92aa35..c8b8378e 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data.json @@ -33,37 +33,37 @@ "content": { "application/json": { "schema": { - "example": { - "token": "some_token", - "user": { + "type": "object" + }, + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } }, - "type": "object" + "ttl": 60, + "refresh_ttl": 20160 } } } @@ -73,10 +73,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "You have entered an incorrect credentials." - }, "type": "object" + }, + "example": { + "error": "You have entered an incorrect credentials." } } } @@ -86,10 +86,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." - }, "type": "object" + }, + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." } } } diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json index 4ed1c387..3532ee78 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json @@ -33,37 +33,37 @@ "content": { "application/json": { "schema": { - "example": { - "token": "some_token", - "user": { + "type": "object" + }, + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } }, - "type": "object" + "ttl": 60, + "refresh_ttl": 20160 } } } @@ -73,10 +73,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "You have entered an incorrect credentials." - }, "type": "object" + }, + "example": { + "error": "You have entered an incorrect credentials." } } } @@ -86,10 +86,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." - }, "type": "object" + }, + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." } } } diff --git a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json index 41ca0b7a..7cc89989 100644 --- a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json @@ -49,36 +49,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/getUsersroles200ResponseObject", "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index b24f158e..f29829c8 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -35,37 +35,37 @@ "content": { "application/json": { "schema": { - "example": { - "token": "some_token", - "user": { + "type": "object" + }, + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } }, - "type": "object" + "ttl": 60, + "refresh_ttl": 20160 } } } @@ -75,10 +75,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "You have entered an incorrect credentials." - }, "type": "object" + }, + "example": { + "error": "You have entered an incorrect credentials." } } } @@ -88,10 +88,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." - }, "type": "object" + }, + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." } } } diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index e46fd75c..ffcfeac8 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json index ed6b51ac..1e4e4d1b 100644 --- a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json @@ -32,34 +32,34 @@ "content": { "application/json": { "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/RemoteDriverTest/tmp_data.json b/tests/fixtures/RemoteDriverTest/tmp_data.json index ad92aa35..c8b8378e 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data.json @@ -33,37 +33,37 @@ "content": { "application/json": { "schema": { - "example": { - "token": "some_token", - "user": { + "type": "object" + }, + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } }, - "type": "object" + "ttl": 60, + "refresh_ttl": 20160 } } } @@ -73,10 +73,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "You have entered an incorrect credentials." - }, "type": "object" + }, + "example": { + "error": "You have entered an incorrect credentials." } } } @@ -86,10 +86,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." - }, "type": "object" + }, + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." } } } diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index 89ce7104..40946295 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/StorageDriverTest/tmp_data.json b/tests/fixtures/StorageDriverTest/tmp_data.json index ad92aa35..c8b8378e 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data.json +++ b/tests/fixtures/StorageDriverTest/tmp_data.json @@ -33,37 +33,37 @@ "content": { "application/json": { "schema": { - "example": { - "token": "some_token", - "user": { + "type": "object" + }, + "example": { + "token": "some_token", + "user": { + "id": 2, + "email": "user@test.com", + "deleted_at": null, + "created_at": "2017-11-16 06:08:34", + "updated_at": "2018-01-01 00:00:00", + "role_id": 2, + "state": "confirmed", + "reset_password_hash": null, + "failed_auth_attempts": 0, + "last_auth_attempt": "2018-01-01 00:00:00", + "first_name": "user", + "last_name": null, + "set_password_hash_created_at": null, + "full_name": "user", + "new_email": "new_email_test2@test.com", + "is_email_verified": true, + "role": { "id": 2, - "email": "user@test.com", - "deleted_at": null, - "created_at": "2017-11-16 06:08:34", - "updated_at": "2018-01-01 00:00:00", - "role_id": 2, - "state": "confirmed", - "reset_password_hash": null, - "failed_auth_attempts": 0, - "last_auth_attempt": "2018-01-01 00:00:00", - "first_name": "user", - "last_name": null, - "set_password_hash_created_at": null, - "full_name": "user", - "new_email": "new_email_test2@test.com", - "is_email_verified": true, - "role": { - "id": 2, - "name": "client", - "created_at": null, - "updated_at": null, - "settable": true - } - }, - "ttl": 60, - "refresh_ttl": 20160 + "name": "client", + "created_at": null, + "updated_at": null, + "settable": true + } }, - "type": "object" + "ttl": 60, + "refresh_ttl": 20160 } } } @@ -73,10 +73,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "You have entered an incorrect credentials." - }, "type": "object" + }, + "example": { + "error": "You have entered an incorrect credentials." } } } @@ -86,10 +86,10 @@ "content": { "application/json": { "schema": { - "example": { - "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." - }, "type": "object" + }, + "example": { + "error": "The limit of failed authorization attempts has been reached. You can't login in next 50 minutes." } } } diff --git a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json index 89ce7104..40946295 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"example":{"error":"You have entered an incorrect credentials."},"type":"object"}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."},"type":"object"}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 3a9abf04..06784af3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -33,12 +33,12 @@ "description": "Forbidden", "content": { "application/json": { - "$ref": "#/definitions/postApiusers403ResponseObject", "schema": { - "type": "object", - "example": { - "message": "This action is unauthorized." - } + "$ref": "#/definitions/postApiusers403ResponseObject", + "type": "object" + }, + "example": { + "message": "This action is unauthorized." } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json index dffe188f..96367298 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json @@ -92,19 +92,19 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject", "schema": { - "example": { + "$ref": "#/definitions/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject", + "type": "object" + }, + "example": { + "id": 2, + "name": "first_client", + "likes_count": 23, + "role": { "id": 2, - "name": "first_client", - "likes_count": 23, - "role": { - "id": 2, - "name": "client" - }, - "type": "reader" + "name": "client" }, - "type": "object" + "type": "reader" } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json index 9249d2e3..ee536d3f 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json @@ -65,19 +65,19 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject", "schema": { - "type": "object", - "example": { + "$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject", + "type": "object" + }, + "example": { + "id": 2, + "name": "first_client", + "likes_count": 23, + "role": { "id": 2, - "name": "first_client", - "likes_count": 23, - "role": { - "id": 2, - "name": "client" - }, - "type": "reader" - } + "name": "client" + }, + "type": "reader" } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json index 59cb5e02..5c8348f4 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json @@ -34,37 +34,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/postUsers200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/postUsers200ResponseObject", "type": "object" - } - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ]} } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json index 4a00aca3..15f009f3 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json @@ -32,37 +32,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/postUsers200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/postUsers200ResponseObject", "type": "object" - } - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ]} } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json index 26717d07..1d8a1f3f 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json @@ -43,34 +43,34 @@ "content": { "application/json": { "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json index 7f2bbdaa..b8ae7269 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json @@ -43,34 +43,34 @@ "content": { "application/json": { "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } @@ -119,11 +119,11 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/patchUsers{id}204ResponseObject", "schema": { - "example": [], + "$ref": "#/definitions/patchUsers{id}204ResponseObject", "type": "object" - } + }, + "example": [] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json index f7da9820..b1b570bb 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json @@ -21,36 +21,36 @@ "description": "OK", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/getUsersroles200ResponseObject", "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json index 584e56c8..5e8b46af 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json @@ -49,36 +49,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ] - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json index dba6aa88..93cd0928 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json @@ -49,36 +49,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/getUsersroles200ResponseObject", "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json index 94039afe..7dd2deb4 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json @@ -49,36 +49,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ] - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json index f8444ca9..eccf4876 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json @@ -49,11 +49,11 @@ "description": "Operation successfully done", "content": { "application/pdf": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": "WwogICAgewogICAgICAgICJpZCI6IDEsCiAgICAgICAgIm5hbWUiOiAiYWRtaW4iLAogICAgICAgICJ1c2VycyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImlkIjogMSwKICAgICAgICAgICAgICAgICJuYW1lIjogImFkbWluIgogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAiaWQiOiAyLAogICAgICAgICJuYW1lIjogImNsaWVudCIsCiAgICAgICAgInVzZXJzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAyLAogICAgICAgICAgICAgICAgIm5hbWUiOiAiZmlyc3RfY2xpZW50IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAzLAogICAgICAgICAgICAgICAgIm5hbWUiOiAic2Vjb25kX2NsaWVudCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==" - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": "WwogICAgewogICAgICAgICJpZCI6IDEsCiAgICAgICAgIm5hbWUiOiAiYWRtaW4iLAogICAgICAgICJ1c2VycyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImlkIjogMSwKICAgICAgICAgICAgICAgICJuYW1lIjogImFkbWluIgogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAiaWQiOiAyLAogICAgICAgICJuYW1lIjogImNsaWVudCIsCiAgICAgICAgInVzZXJzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAyLAogICAgICAgICAgICAgICAgIm5hbWUiOiAiZmlyc3RfY2xpZW50IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAzLAogICAgICAgICAgICAgICAgIm5hbWUiOiAic2Vjb25kX2NsaWVudCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==" } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json index 93565547..04db6e26 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json @@ -49,11 +49,11 @@ "description": "Operation successfully done", "content": { "text/plain": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": "[\n {\n \"id\": 1,\n \"name\": \"admin\",\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"admin\"\n }\n ]\n }\n]" - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": "[\n {\n \"id\": 1,\n \"name\": \"admin\",\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"admin\"\n }\n ]\n }\n]" } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json index fd880261..5a8e761d 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json @@ -49,36 +49,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ], + "$ref": "#/definitions/getUsersroles200ResponseObject", "type": "object" - } + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json index 83e416e0..fc59579e 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json @@ -33,36 +33,36 @@ "description": "The operation was completed successfully", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ] - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json index 768a64ec..96e16a64 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_info.json @@ -41,33 +41,38 @@ "responses": { "200": { "description": "Operation successfully done", - "schema": { - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] + "content": { + "application/json": { + "schema": { + "type": "object" }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ] + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] + } } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json index 114f8ec0..de20cbd5 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json @@ -33,36 +33,36 @@ "description": "Operation successfully done", "content": { "application/json": { - "$ref": "#/definitions/getUsersroles200ResponseObject", "schema": { - "type": "object", - "example": [ - { - "id": 1, - "name": "admin", - "users": [ - { - "id": 1, - "name": "admin" - } - ] - }, - { - "id": 2, - "name": "client", - "users": [ - { - "id": 2, - "name": "first_client" - }, - { - "id": 3, - "name": "second_client" - } - ] - } - ] - } + "$ref": "#/definitions/getUsersroles200ResponseObject", + "type": "object" + }, + "example": [ + { + "id": 1, + "name": "admin", + "users": [ + { + "id": 1, + "name": "admin" + } + ] + }, + { + "id": 2, + "name": "client", + "users": [ + { + "id": 2, + "name": "first_client" + }, + { + "id": 3, + "name": "second_client" + } + ] + } + ] } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json index 5ea1085e..c2c88103 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json @@ -21,59 +21,59 @@ "description": "OK", "content": { "application\/json": { - "$ref": "#/definitions/getApiusers200ResponseObject", "schema": { - "example": { - "current_page": 1, - "data": [ - { - "id": 1, - "first_name": "Billy", - "last_name": "Coleman", - "email": "billy.coleman@example.com", - "created_at": null, - "updated_at": null, - "role_id": 1, - "date_of_birth": "1986-05-20", - "phone": "+79535482530", - "position": "admin", - "starts_on": "2022-04-16 00:00:00", - "hr_id": null, - "manager_id": null, - "lead_id": null, - "avatar_id": null, - "deleted_at": null, - "company_id": 1 - } - ], - "first_page_url": "http:\/\/localhost\/api\/users?page=1", - "from": 1, - "last_page": 1, - "last_page_url": "http:\/\/localhost\/api\/users?page=1", - "links": [ - { - "url": null, - "label": "« Previous", - "active": false - }, - { - "url": "http:\/\/localhost\/api\/users?page=1", - "label": "1", - "active": true - }, - { - "url": null, - "label": "Next »", - "active": false - }], - "next_page_url": null, - "path": "http:\/\/localhost\/api\/users", - "per_page": 20, - "prev_page_url": null, - "to": 1, - "total": 1 - }, + "$ref": "#/definitions/getApiusers200ResponseObject", "type": "object" + }, + "example": { + "current_page": 1, + "data": [ + { + "id": 1, + "first_name": "Billy", + "last_name": "Coleman", + "email": "billy.coleman@example.com", + "created_at": null, + "updated_at": null, + "role_id": 1, + "date_of_birth": "1986-05-20", + "phone": "+79535482530", + "position": "admin", + "starts_on": "2022-04-16 00:00:00", + "hr_id": null, + "manager_id": null, + "lead_id": null, + "avatar_id": null, + "deleted_at": null, + "company_id": 1 + } + ], + "first_page_url": "http:\/\/localhost\/api\/users?page=1", + "from": 1, + "last_page": 1, + "last_page_url": "http:\/\/localhost\/api\/users?page=1", + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/localhost\/api\/users?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + }], + "next_page_url": null, + "path": "http:\/\/localhost\/api\/users", + "per_page": 20, + "prev_page_url": null, + "to": 1, + "total": 1 } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json index 55e7b068..c763f9aa 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json @@ -47,59 +47,59 @@ "description": "Operation successfully done", "content": { "application\/json": { - "$ref": "#/definitions/getApiusers200ResponseObject", "schema": { - "example": { - "current_page": 1, - "data": [ - { - "id": 1, - "first_name": "Billy", - "last_name": "Coleman", - "email": "billy.coleman@example.com", - "created_at": null, - "updated_at": null, - "role_id": 1, - "date_of_birth": "1986-05-20", - "phone": "+79535482530", - "position": "admin", - "starts_on": "2022-04-16 00:00:00", - "hr_id": null, - "manager_id": null, - "lead_id": null, - "avatar_id": null, - "deleted_at": null, - "company_id": 1 - } - ], - "first_page_url": "http:\/\/localhost\/api\/users?page=1", - "from": 1, - "last_page": 1, - "last_page_url": "http:\/\/localhost\/api\/users?page=1", - "links": [ - { - "url": null, - "label": "« Previous", - "active": false - }, - { - "url": "http:\/\/localhost\/api\/users?page=1", - "label": "1", - "active": true - }, - { - "url": null, - "label": "Next »", - "active": false - }], - "next_page_url": null, - "path": "http:\/\/localhost\/api\/users", - "per_page": 20, - "prev_page_url": null, - "to": 1, - "total": 1 - }, + "$ref": "#/definitions/getApiusers200ResponseObject", "type": "object" + }, + "example": { + "current_page": 1, + "data": [ + { + "id": 1, + "first_name": "Billy", + "last_name": "Coleman", + "email": "billy.coleman@example.com", + "created_at": null, + "updated_at": null, + "role_id": 1, + "date_of_birth": "1986-05-20", + "phone": "+79535482530", + "position": "admin", + "starts_on": "2022-04-16 00:00:00", + "hr_id": null, + "manager_id": null, + "lead_id": null, + "avatar_id": null, + "deleted_at": null, + "company_id": 1 + } + ], + "first_page_url": "http:\/\/localhost\/api\/users?page=1", + "from": 1, + "last_page": 1, + "last_page_url": "http:\/\/localhost\/api\/users?page=1", + "links": [ + { + "url": null, + "label": "« Previous", + "active": false + }, + { + "url": "http:\/\/localhost\/api\/users?page=1", + "label": "1", + "active": true + }, + { + "url": null, + "label": "Next »", + "active": false + }], + "next_page_url": null, + "path": "http:\/\/localhost\/api\/users", + "per_page": 20, + "prev_page_url": null, + "to": 1, + "total": 1 } } } From c69c90b35e082ca1fe1de1dc7115f36c12bb17ef Mon Sep 17 00:00:00 2001 From: aizlee Date: Mon, 16 Sep 2024 16:15:13 +0600 Subject: [PATCH 6/8] feat: implemented components --- src/Services/SwaggerService.php | 26 +++--- src/Validators/SwaggerSpecValidator.php | 8 +- tests/SwaggerServiceTest.php | 2 +- .../AutoDocControllerTest/tmp_data.json | 40 +++++---- .../tmp_data_with_additional_paths.json | 72 +++++++-------- .../tmp_data_search_roles_request.json | 24 ++--- tests/fixtures/LocalDriverTest/tmp_data.json | 40 +++++---- .../tmp_data_non_formatted.json | 2 +- .../tmp_data_search_roles_request.json | 4 +- tests/fixtures/RemoteDriverTest/tmp_data.json | 40 +++++---- .../tmp_data_non_formatted.json | 2 +- .../fixtures/StorageDriverTest/tmp_data.json | 40 +++++---- .../tmp_data_non_formatted.json | 2 +- ...ormat__missing_field__definition_type.json | 38 ++++---- .../tmp_data_create_user_request.json | 58 ++++++------ ...data_get_route_parameters_description.json | 40 +++++---- .../tmp_data_get_user_request.json | 40 +++++---- .../tmp_data_post_user_request.json | 74 ++++++++-------- ..._post_user_request_with_object_params.json | 70 ++++++++------- .../tmp_data_put_user_request.json | 32 +++---- ...user_request_with_early_generated_doc.json | 54 ++++++------ ...data_request_with_empty_data_and_info.json | 4 +- .../tmp_data_request_with_empty_data_jwt.json | 4 +- ..._data_request_with_empty_data_laravel.json | 4 +- ...mp_data_request_with_empty_data_query.json | 4 +- ...tmp_data_search_roles_closure_request.json | 24 ++--- .../tmp_data_search_roles_request.json | 8 +- ...ch_roles_request_invalid_content_type.json | 22 ++--- ...ata_search_roles_request_jwt_security.json | 24 ++--- ...search_roles_request_laravel_security.json | 24 ++--- .../tmp_data_search_roles_request_pdf.json | 8 +- ..._data_search_roles_request_plain_text.json | 24 ++--- ...a_search_roles_request_query_security.json | 24 ++--- ...search_roles_request_with_annotations.json | 24 ++--- ...earch_roles_request_without_rule_type.json | 24 ++--- .../tmp_data_search_users_empty_request.json | 88 ++++++++++--------- .../tmp_data_search_users_request.json | 88 ++++++++++--------- .../Traits/SwaggerServiceMockTrait.php | 2 +- 38 files changed, 587 insertions(+), 521 deletions(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index a186cfa7..5ad941f8 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -143,7 +143,9 @@ protected function generateEmptyData(): array ['url' => $this->getAppUrl() . $this->config['basePath']], ], 'paths' => [], - 'definitions' => $this->config['definitions'], + 'components' => [ + 'schemas' => $this->config['definitions'], + ], 'info' => $this->prepareInfo($this->config['info']) ]; @@ -309,7 +311,7 @@ protected function saveResponseSchema(?array $content, string $definition): void $this->saveObjectResponseDefinitions($content, $schemaProperties, $definition); } - $this->data['definitions'][$definition] = [ + $this->data['components']['schemas'][$definition] = [ 'type' => $schemaType, 'properties' => $schemaProperties ]; @@ -331,7 +333,9 @@ protected function saveListResponseDefinitions(array $content, array &$schemaPro protected function saveObjectResponseDefinitions(array $content, array &$schemaProperties, string $definition): void { - $properties = Arr::get($this->data['definitions'], $definition, []); + $definitions = (!empty($this->data['components']['schemas'])) ? $this->data['components']['schemas'] : []; + + $properties = Arr::get($definitions, $definition, []); foreach ($content as $name => $value) { $property = Arr::get($properties, "properties.{$name}", []); @@ -397,7 +401,7 @@ protected function parseResponse($response) $this->saveResponseSchema($content, $definition); if (is_array($this->item['responses'][$code])) { - $this->item['responses'][$code]['content'][$produce]['schema']['$ref'] = "#/definitions/{$definition}"; + $this->item['responses'][$code]['content'][$produce]['schema']['$ref'] = "#/components/schemas/{$definition}"; } } @@ -535,7 +539,7 @@ protected function savePostRequestParameters($actionName, $rules, array $attribu 'content' => [ $type => [ 'schema' => [ - "\$ref" => "#/definitions/{$actionName}Object", + "\$ref" => "#/components/schemas/{$actionName}Object", ], ], ], @@ -573,7 +577,7 @@ protected function saveDefinitions($objectName, $rules, $attributes, array $anno } $data['example'] = $this->generateExample($data['properties']); - $this->data['definitions'][$objectName . 'Object'] = $data; + $this->data['components']['schemas'][$objectName . 'Object'] = $data; } protected function getParameterType(array $validation): string @@ -614,8 +618,8 @@ protected function requestHasMoreProperties($actionName): bool { $requestParametersCount = count($this->request->all()); - if (isset($this->data['definitions'][$actionName . 'Object']['properties'])) { - $objectParametersCount = count($this->data['definitions'][$actionName . 'Object']['properties']); + if (isset($this->data['components']['schemas'][$actionName . 'Object']['properties'])) { + $objectParametersCount = count($this->data['components']['schemas'][$actionName . 'Object']['properties']); } else { $objectParametersCount = 0; } @@ -993,11 +997,11 @@ protected function mergeOpenAPIDocs(array &$documentation, array $additionalDocu } } - $definitions = array_keys($additionalDocumentation['definitions']); + $definitions = array_keys($additionalDocumentation['components']['schemas']); foreach ($definitions as $definition) { - if (empty($documentation['definitions'][$definition])) { - $documentation['definitions'][$definition] = $additionalDocumentation['definitions'][$definition]; + if (empty($documentation['components']['schemas'][$definition])) { + $documentation['components']['schemas'][$definition] = $additionalDocumentation['components']['schemas'][$definition]; } } } diff --git a/src/Validators/SwaggerSpecValidator.php b/src/Validators/SwaggerSpecValidator.php index 16df0f36..354d3ff0 100644 --- a/src/Validators/SwaggerSpecValidator.php +++ b/src/Validators/SwaggerSpecValidator.php @@ -48,7 +48,7 @@ class SwaggerSpecValidator ]; public const REQUIRED_FIELDS = [ - 'definition' => ['type'], + 'components' => ['type'], 'doc' => ['openapi', 'info', 'paths'], 'info' => ['title', 'version'], 'item' => ['type'], @@ -145,10 +145,10 @@ protected function validatePaths(): void protected function validateDefinitions(): void { - $definitions = Arr::get($this->doc, 'definitions', []); + $definitions = Arr::get($this->doc, 'components.schemas', []); foreach ($definitions as $index => $definition) { - $this->validateFieldsPresent(self::REQUIRED_FIELDS['definition'], "definitions.{$index}"); + $this->validateFieldsPresent(self::REQUIRED_FIELDS['components'], "components.schemas.{$index}"); } } @@ -431,7 +431,7 @@ protected function validateRefs(): void !empty($refFilename) ? json_decode(file_get_contents($refFilename), true) : $this->doc, - $refParentKey + str_replace('/', '.', $refParentKey), ); if (!empty($missingRefs)) { diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 9355fb99..53b6a249 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -218,7 +218,7 @@ public static function getConstructorInvalidTmpData(): array [ 'tmpDoc' => 'documentation/invalid_format__missing_field__definition_type', 'exception' => MissingFieldException::class, - 'exceptionMessage' => "Validation failed. 'definitions.authloginObject' should have " + 'exceptionMessage' => "Validation failed. 'components.schemas.authloginObject' should have " . "required fields: type.", ], [ diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data.json b/tests/fixtures/AutoDocControllerTest/tmp_data.json index c8b8378e..4fd31f5a 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data.json @@ -20,7 +20,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -101,26 +101,28 @@ } } }, - "definitions": { - "authloginObject": { - "type": "object", - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } - }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" } } }, diff --git a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json index 3532ee78..a0246103 100644 --- a/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json +++ b/tests/fixtures/AutoDocControllerTest/tmp_data_with_additional_paths.json @@ -20,7 +20,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -114,7 +114,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -210,7 +210,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/apiusersObject" + "$ref": "#/components/schemas/apiusersObject" } }, "required": true, @@ -290,42 +290,44 @@ } } }, - "definitions": { - "authloginObject": { - "type": "object", - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" - } - }, - "apiusersObject": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" + "apiusersObject": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + } + }, + "required": [ + "query" + ], + "example": { + "first_name": "andrey", + "last_name": "voronin" } - }, - "required": [ - "query" - ], - "example": { - "first_name": "andrey", - "last_name": "voronin" } } }, diff --git a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json index 7cc89989..95a3088b 100644 --- a/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/AutoDocMiddlewareTest/tmp_data_search_roles_request.json @@ -50,7 +50,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -90,16 +90,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/LocalDriverTest/tmp_data.json b/tests/fixtures/LocalDriverTest/tmp_data.json index f29829c8..06cca4c0 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data.json +++ b/tests/fixtures/LocalDriverTest/tmp_data.json @@ -22,7 +22,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -103,26 +103,28 @@ } } }, - "definitions": { - "authloginObject": { - "type": "object", - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } - }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" } } }, diff --git a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json index ffcfeac8..e36efe47 100644 --- a/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/LocalDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","servers":[{"url":"http:\/\/localhost"}],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"components":{"schemas":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json index 1e4e4d1b..1c3c83c8 100644 --- a/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/PushDocumentationCommandTest/tmp_data_search_roles_request.json @@ -70,7 +70,9 @@ } } }, - "definitions": {}, + "components": { + "schemas": {} + }, "info": { "description": "This is automatically collected documentation", "version": "0.0.0", diff --git a/tests/fixtures/RemoteDriverTest/tmp_data.json b/tests/fixtures/RemoteDriverTest/tmp_data.json index c8b8378e..4fd31f5a 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data.json @@ -20,7 +20,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -101,26 +101,28 @@ } } }, - "definitions": { - "authloginObject": { - "type": "object", - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } - }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" } } }, diff --git a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json index 40946295..5576c6a6 100644 --- a/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/RemoteDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"components":{"schemas":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/StorageDriverTest/tmp_data.json b/tests/fixtures/StorageDriverTest/tmp_data.json index c8b8378e..4fd31f5a 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data.json +++ b/tests/fixtures/StorageDriverTest/tmp_data.json @@ -20,7 +20,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/authloginObject" + "$ref": "#/components/schemas/authloginObject" } }, "required": true, @@ -101,26 +101,28 @@ } } }, - "definitions": { - "authloginObject": { - "type": "object", - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } - }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" } } }, diff --git a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json index 40946295..5576c6a6 100644 --- a/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json +++ b/tests/fixtures/StorageDriverTest/tmp_data_non_formatted.json @@ -1 +1 @@ -{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/definitions\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"definitions":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file +{"openapi":"3.1.0","host":"localhost","basePath":"\/","schemes":[],"paths":{"\/auth\/login":{"post":{"tags":["auth"],"consumes":["application\/json"],"produces":["application\/json"],"parameters":[],"requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/authloginObject"}},"required":true,"description":""}},"responses":{"200":{"description":"Operation successfully done","content":{"application\/json":{"schema":{"type":"object"},"example":{"token":"some_token","user":{"id":2,"email":"user@test.com","deleted_at":null,"created_at":"2017-11-16 06:08:34","updated_at":"2018-01-01 00:00:00","role_id":2,"state":"confirmed","reset_password_hash":null,"failed_auth_attempts":0,"last_auth_attempt":"2018-01-01 00:00:00","first_name":"user","last_name":null,"set_password_hash_created_at":null,"full_name":"user","new_email":"new_email_test2@test.com","is_email_verified":true,"role":{"id":2,"name":"client","created_at":null,"updated_at":null,"settable":true}},"ttl":60,"refresh_ttl":20160}}}},"401":{"description":"Unauthorized","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"You have entered an incorrect credentials."}}}},"400":{"description":"Bad Request","content":{"application\/json":{"schema":{"type":"object"},"example":{"error":"The limit of failed authorization attempts has been reached. You can't login in next 50 minutes."}}}}},"security":[],"description":"","summary":"login"}}},"components":{"schemas":{"authloginObject":{"type":"object","properties":{"email":{"type":"string","description":"2"},"password":{"type":"string","description":""}},"required":["email","password"],"example":{"email":"admin@test.com","password":"123"}}}},"info":{"description":"This is automatically collected documentation","version":"0.0.0","title":"Project Title","termsOfService":"","contact":{"email":"your@email.com"}}} \ No newline at end of file diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json index 73b4f514..a82adfdf 100644 --- a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__missing_field__definition_type.json @@ -24,7 +24,7 @@ "description": "", "required": true, "schema": { - "$ref": "#\/definitions\/authloginObject" + "$ref": "#\/components\/schemas\/authloginObject" } } ], @@ -87,25 +87,27 @@ } } }, - "definitions": { - "authloginObject": { - "properties": { - "email": { - "type": "string", - "description": "2" + "components": { + "schemas": { + "authloginObject": { + "properties": { + "email": { + "type": "string", + "description": "2" + }, + "password": { + "type": "string", + "description": "" + } }, - "password": { - "type": "string", - "description": "" + "required": [ + "email", + "password" + ], + "example": { + "email": "admin@test.com", + "password": "123" } - }, - "required": [ - "email", - "password" - ], - "example": { - "email": "admin@test.com", - "password": "123" } } }, diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json index 06784af3..f9010fda 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_create_user_request.json @@ -19,7 +19,7 @@ "content": { "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/definitions/apiusersObject" + "$ref": "#/components/schemas/apiusersObject" } } }, @@ -34,7 +34,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/postApiusers403ResponseObject", + "$ref": "#/components/schemas/postApiusers403ResponseObject", "type": "object" }, "example": { @@ -51,36 +51,38 @@ } } }, - "definitions": { - "apiusersObject": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" + "components": { + "schemas": { + "apiusersObject": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + }, + "user_id": { + "type": "integer", + "description": "with_to_array_rule_string_name" + }, + "is_email_enabled": { + "type": "string", + "description": "test_rule_without_to_string" + } }, - "user_id": { - "type": "integer", - "description": "with_to_array_rule_string_name" + "required": { + "0": "query" }, - "is_email_enabled": { - "type": "string", - "description": "test_rule_without_to_string" + "example": { + "first_name": "andrey", + "last_name": "voronin" } }, - "required": { - "0": "query" - }, - "example": { - "first_name": "andrey", - "last_name": "voronin" - } - }, - "postApiusers403ResponseObject": { - "type": "object", - "properties": { - "message": { - "type": "string" + "postApiusers403ResponseObject": { + "type": "object", + "properties": { + "message": { + "type": "string" + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json index 96367298..1590e348 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json @@ -93,7 +93,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject", + "$ref": "#/components/schemas/getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject", "type": "object" }, "example": { @@ -117,24 +117,26 @@ } } }, - "definitions": { - "getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject": { - "type": "object", - "properties": { - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "likes_count": { - "type": "integer" - }, - "role": { - "type": "array" - }, - "type": { - "type": "string" + "components": { + "schemas": { + "getV{versions}users{id}{someString}{uuid}{withoutConditional}200ResponseObject": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "likes_count": { + "type": "integer" + }, + "role": { + "type": "array" + }, + "type": { + "type": "string" + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json index ee536d3f..00412bbf 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_get_user_request.json @@ -66,7 +66,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsers{id}assignRole{roleId}200ResponseObject", + "$ref": "#/components/schemas/getUsers{id}assignRole{roleId}200ResponseObject", "type": "object" }, "example": { @@ -90,24 +90,26 @@ } } }, - "definitions": { - "getUsers{id}assignRole{roleId}200ResponseObject": { - "type": "object", - "properties": { - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "likes_count": { - "type": "integer" - }, - "role": { - "type": "array" - }, - "type": { - "type": "string" + "components": { + "schemas": { + "getUsers{id}assignRole{roleId}200ResponseObject": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "likes_count": { + "type": "integer" + }, + "role": { + "type": "array" + }, + "type": { + "type": "string" + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json index 5c8348f4..45bc172d 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request.json @@ -24,7 +24,7 @@ "content": { "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/definitions/usersObject" + "$ref": "#/components/schemas/usersObject" } } } @@ -35,7 +35,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/postUsers200ResponseObject", + "$ref": "#/components/schemas/postUsers200ResponseObject", "type": "object" }, "example": [ @@ -78,43 +78,45 @@ } } }, - "definitions": { - "usersObject": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" + "components": { + "schemas": { + "usersObject": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + }, + "user_id": { + "type": "integer", + "description": "with_to_array_rule_string_name" + }, + "is_email_enabled": { + "type": "string", + "description": "test_rule_without_to_string" + } }, - "user_id": { - "type": "integer", - "description": "with_to_array_rule_string_name" + "example": { + "users": [ + 1, + 2 + ], + "query": null }, - "is_email_enabled": { - "type": "string", - "description": "test_rule_without_to_string" - } - }, - "example": { - "users": [ - 1, - 2 - ], - "query": null + "required": [ + "query" + ] }, - "required": [ - "query" - ] - }, - "postUsers200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "postUsers200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json index 15f009f3..93ad0910 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_post_user_request_with_object_params.json @@ -20,7 +20,7 @@ "content": { "application/x-www-form-urlencoded": { "schema": { - "$ref": "#/definitions/usersObject" + "$ref": "#/components/schemas/usersObject" } } }, @@ -33,7 +33,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/postUsers200ResponseObject", + "$ref": "#/components/schemas/postUsers200ResponseObject", "type": "object" }, "example": [ @@ -76,41 +76,43 @@ } } }, - "definitions": { - "usersObject": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" + "components": { + "schemas": { + "usersObject": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + }, + "user_id": { + "type": "integer", + "description": "with_to_array_rule_string_name" + }, + "is_email_enabled": { + "type": "string", + "description": "test_rule_without_to_string" + } }, - "user_id": { - "type": "integer", - "description": "with_to_array_rule_string_name" + "example": { + "query": null, + "first_name": "John", + "last_name": "Doe", + "license": "[uploaded_file]", + "notification_settings": "RonasIT\\Support\\Tests\\Support\\Mock\\TestNotificationSetting" }, - "is_email_enabled": { - "type": "string", - "description": "test_rule_without_to_string" - } + "required": ["query"] }, - "example": { - "query": null, - "first_name": "John", - "last_name": "Doe", - "license": "[uploaded_file]", - "notification_settings": "RonasIT\\Support\\Tests\\Support\\Mock\\TestNotificationSetting" - }, - "required": ["query"] - }, - "postUsers200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "postUsers200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json index 1d8a1f3f..296aa1fa 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request.json @@ -30,7 +30,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/users{id}Object" + "$ref": "#/components/schemas/users{id}Object" } } }, @@ -86,20 +86,22 @@ } } }, - "definitions": { - "users{id}Object": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" - } - }, - "example": { - "name": "Ryan", - "query": null - }, - "required": ["query"] + "components": { + "schemas": { + "users{id}Object": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + } + }, + "example": { + "name": "Ryan", + "query": null + }, + "required": ["query"] + } } }, "info": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json index b8ae7269..3ee7ae7d 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_put_user_request_with_early_generated_doc.json @@ -30,7 +30,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/users{id}Object" + "$ref": "#/components/schemas/users{id}Object" } } }, @@ -107,7 +107,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/users{id}Object" + "$ref": "#/components/schemas/users{id}Object" } } }, @@ -120,7 +120,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/patchUsers{id}204ResponseObject", + "$ref": "#/components/schemas/patchUsers{id}204ResponseObject", "type": "object" }, "example": [] @@ -139,32 +139,34 @@ } } }, - "definitions": { - "users{id}Object": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "" + "components": { + "schemas": { + "users{id}Object": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "" + }, + "user_id": { + "type": "integer", + "description": "with_to_array_rule_string_name" + }, + "is_email_enabled": { + "type": "string", + "description": "test_rule_without_to_string" + } }, - "user_id": { - "type": "integer", - "description": "with_to_array_rule_string_name" + "example": { + "name": "Ryan", + "query": null }, - "is_email_enabled": { - "type": "string", - "description": "test_rule_without_to_string" - } - }, - "example": { - "name": "Ryan", - "query": null + "required": ["query"] }, - "required": ["query"] - }, - "patchUsers{id}204ResponseObject": { - "type": "object", - "properties": [] + "patchUsers{id}204ResponseObject": { + "type": "object", + "properties": [] + } } }, "info": { diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json index 9eae2d00..e6bd61b2 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json @@ -6,6 +6,8 @@ } ], "paths": [], - "definitions": [], + "components": { + "schemas": [] + }, "info": [] } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json index c5b613b2..016eceeb 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json @@ -6,7 +6,9 @@ } ], "paths": [], - "definitions": [], + "components": { + "schemas": [] + }, "info": { "description": "This is automatically collected documentation", "version": "0.0.0", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json index 8b8d6891..69e44879 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json @@ -6,7 +6,9 @@ } ], "paths": [], - "definitions": [], + "components": { + "schemas": [] + }, "info": { "description": "This is automatically collected documentation", "version": "0.0.0", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json index f29a0984..70d01625 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json @@ -6,7 +6,9 @@ } ], "paths": [], - "definitions": [], + "components": { + "schemas": [] + }, "info": { "description": "This is automatically collected documentation", "version": "0.0.0", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json index b1b570bb..a0ec5c3b 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json @@ -22,7 +22,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -60,16 +60,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json index 5e8b46af..813d24d1 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json @@ -50,7 +50,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -90,8 +90,9 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { + "components": { + "schemas": { + "getUsersroles200ResponseObject": { "type": "array", "properties": { "items": { @@ -103,6 +104,7 @@ } } } + } }, "info": { "description": "This is automatically collected documentation", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json index f4220b53..afc277d9 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_invalid_content_type.json @@ -54,16 +54,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json index 93cd0928..a6d8d26c 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json @@ -50,7 +50,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -90,16 +90,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json index 7dd2deb4..8f546f74 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json @@ -50,7 +50,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -90,16 +90,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json index eccf4876..6703f968 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_pdf.json @@ -50,7 +50,7 @@ "content": { "application/pdf": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": "WwogICAgewogICAgICAgICJpZCI6IDEsCiAgICAgICAgIm5hbWUiOiAiYWRtaW4iLAogICAgICAgICJ1c2VycyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImlkIjogMSwKICAgICAgICAgICAgICAgICJuYW1lIjogImFkbWluIgogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAiaWQiOiAyLAogICAgICAgICJuYW1lIjogImNsaWVudCIsCiAgICAgICAgInVzZXJzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAyLAogICAgICAgICAgICAgICAgIm5hbWUiOiAiZmlyc3RfY2xpZW50IgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiaWQiOiAzLAogICAgICAgICAgICAgICAgIm5hbWUiOiAic2Vjb25kX2NsaWVudCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==" @@ -65,8 +65,9 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { + "components": { + "schemas": { + "getUsersroles200ResponseObject": { "type": "array", "properties": { "items": { @@ -78,6 +79,7 @@ } } } + } }, "info": { "description": "This is automatically collected documentation", diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json index 04db6e26..23bf1386 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_plain_text.json @@ -50,7 +50,7 @@ "content": { "text/plain": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": "[\n {\n \"id\": 1,\n \"name\": \"admin\",\n \"users\": [\n {\n \"id\": 1,\n \"name\": \"admin\"\n }\n ]\n }\n]" @@ -65,16 +65,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json index 5a8e761d..0b154949 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json @@ -50,7 +50,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -90,16 +90,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json index fc59579e..b6dffc27 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_with_annotations.json @@ -34,7 +34,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -74,16 +74,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json index de20cbd5..7289339c 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_without_rule_type.json @@ -34,7 +34,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/definitions/getUsersroles200ResponseObject", + "$ref": "#/components/schemas/getUsersroles200ResponseObject", "type": "object" }, "example": [ @@ -74,16 +74,18 @@ } } }, - "definitions": { - "getUsersroles200ResponseObject": { - "type": "array", - "properties": { - "items": { - "allOf": [ - { - "type": "array" - } - ] + "components": { + "schemas": { + "getUsersroles200ResponseObject": { + "type": "array", + "properties": { + "items": { + "allOf": [ + { + "type": "array" + } + ] + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json index c2c88103..30fae821 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_empty_request.json @@ -22,7 +22,7 @@ "content": { "application\/json": { "schema": { - "$ref": "#/definitions/getApiusers200ResponseObject", + "$ref": "#/components/schemas/getApiusers200ResponseObject", "type": "object" }, "example": { @@ -85,48 +85,50 @@ } } }, - "definitions": { - "getApiusers200ResponseObject": { - "type": "object", - "properties": { - "current_page": { - "type": "integer" - }, - "data": { - "type": "array" - }, - "first_page_url": { - "type": "string" - }, - "from": { - "type": "integer" - }, - "last_page": { - "type": "integer" - }, - "last_page_url": { - "type": "string" - }, - "links": { - "type": "array" - }, - "next_page_url": { - "nullable": true - }, - "path": { - "type": "string" - }, - "per_page": { - "type": "integer" - }, - "prev_page_url": { - "nullable": true - }, - "to": { - "type": "integer" - }, - "total": { - "type": "integer" + "components": { + "schemas": { + "getApiusers200ResponseObject": { + "type": "object", + "properties": { + "current_page": { + "type": "integer" + }, + "data": { + "type": "array" + }, + "first_page_url": { + "type": "string" + }, + "from": { + "type": "integer" + }, + "last_page": { + "type": "integer" + }, + "last_page_url": { + "type": "string" + }, + "links": { + "type": "array" + }, + "next_page_url": { + "nullable": true + }, + "path": { + "type": "string" + }, + "per_page": { + "type": "integer" + }, + "prev_page_url": { + "nullable": true + }, + "to": { + "type": "integer" + }, + "total": { + "type": "integer" + } } } } diff --git a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json index c763f9aa..ae330da4 100644 --- a/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json +++ b/tests/fixtures/SwaggerServiceTest/tmp_data_search_users_request.json @@ -48,7 +48,7 @@ "content": { "application\/json": { "schema": { - "$ref": "#/definitions/getApiusers200ResponseObject", + "$ref": "#/components/schemas/getApiusers200ResponseObject", "type": "object" }, "example": { @@ -113,48 +113,50 @@ } } }, - "definitions": { - "getApiusers200ResponseObject": { - "type": "object", - "properties": { - "current_page": { - "type": "integer" - }, - "data": { - "type": "array" - }, - "first_page_url": { - "type": "string" - }, - "from": { - "type": "integer" - }, - "last_page": { - "type": "integer" - }, - "last_page_url": { - "type": "string" - }, - "links": { - "type": "array" - }, - "next_page_url": { - "nullable": true - }, - "path": { - "type": "string" - }, - "per_page": { - "type": "integer" - }, - "prev_page_url": { - "nullable": true - }, - "to": { - "type": "integer" - }, - "total": { - "type": "integer" + "components": { + "schemas": { + "getApiusers200ResponseObject": { + "type": "object", + "properties": { + "current_page": { + "type": "integer" + }, + "data": { + "type": "array" + }, + "first_page_url": { + "type": "string" + }, + "from": { + "type": "integer" + }, + "last_page": { + "type": "integer" + }, + "last_page_url": { + "type": "string" + }, + "links": { + "type": "array" + }, + "next_page_url": { + "nullable": true + }, + "path": { + "type": "string" + }, + "per_page": { + "type": "integer" + }, + "prev_page_url": { + "nullable": true + }, + "to": { + "type": "integer" + }, + "total": { + "type": "integer" + } } } } diff --git a/tests/support/Traits/SwaggerServiceMockTrait.php b/tests/support/Traits/SwaggerServiceMockTrait.php index f1839728..d3382a86 100644 --- a/tests/support/Traits/SwaggerServiceMockTrait.php +++ b/tests/support/Traits/SwaggerServiceMockTrait.php @@ -21,7 +21,7 @@ protected function mockDriverGetEmptyAndSaveTmpData( ->willReturn( empty($tmpData) ? $tmpData - : array_merge($tmpData, ['paths' => [], 'definitions' => []]) + : array_merge($tmpData, ['paths' => [], 'components' => []]) ); $driver From 601a8fa2fb1d0331518a4c5628c542a2ed256a9d Mon Sep 17 00:00:00 2001 From: aizlee Date: Fri, 20 Sep 2024 13:56:20 +0600 Subject: [PATCH 7/8] test: check unsupported bodyRequest format --- src/Validators/SwaggerSpecValidator.php | 6 +- tests/SwaggerServiceTest.php | 10 + ...format__request_body__invalid_content.json | 42 +++ ...valid_format__response__invalid_items.json | 256 ++++++++++++++++++ 4 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/SwaggerServiceTest/documentation/invalid_format__request_body__invalid_content.json create mode 100644 tests/fixtures/SwaggerServiceTest/documentation/invalid_format__response__invalid_items.json diff --git a/src/Validators/SwaggerSpecValidator.php b/src/Validators/SwaggerSpecValidator.php index 354d3ff0..bbaf8521 100644 --- a/src/Validators/SwaggerSpecValidator.php +++ b/src/Validators/SwaggerSpecValidator.php @@ -202,10 +202,10 @@ protected function validateResponse(array $response, string $statusCode, string array_merge(self::SCHEMA_TYPES, ['file']), "{$responseId}.schema" ); - } - if (!empty($response['items'])) { - $this->validateItems($response['items'], "{$responseId}.items"); + if (!empty($response['schema']['items'])) { + $this->validateItems($response['schema']['items'], "{$responseId}.schema.items"); + } } } diff --git a/tests/SwaggerServiceTest.php b/tests/SwaggerServiceTest.php index 53b6a249..437e3a44 100644 --- a/tests/SwaggerServiceTest.php +++ b/tests/SwaggerServiceTest.php @@ -289,6 +289,16 @@ public static function getConstructorInvalidTmpData(): array 'exception' => InvalidSwaggerSpecException::class, 'exceptionMessage' => "Validation failed. Field 'securityDefinitions.0.in' has an invalid value: invalid. Allowed values: query, header.", ], + [ + 'tmpDoc' => 'documentation/invalid_format__request_body__invalid_content', + 'exception' => InvalidSwaggerSpecException::class, + 'exceptionMessage' => "Validation failed. Operation 'paths./users/{id}.post' has body parameters. Only one or the other is allowed.", + ], + [ + 'tmpDoc' => 'documentation/invalid_format__response__invalid_items', + 'exception' => InvalidSwaggerSpecException::class, + 'exceptionMessage' => "Validation failed. 'paths./users/{id}.post.responses.200.schema.items' should have required fields: type.", + ], ]; } diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__request_body__invalid_content.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__request_body__invalid_content.json new file mode 100644 index 00000000..3ba956ca --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__request_body__invalid_content.json @@ -0,0 +1,42 @@ +{ + "openapi": "3.1.0", + "info": { + "version": "1.0.0", + "title": "Invalid API" + }, + "paths": { + "/users/{id}": { + "post": { + "consumes": [], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "image/png": { + "items": [] + } + }, + "required": true, + "description": "" + }, + "responses": { + "default": { + "description": "hello world" + } + } + } + } + } +} diff --git a/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__response__invalid_items.json b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__response__invalid_items.json new file mode 100644 index 00000000..aada4ce5 --- /dev/null +++ b/tests/fixtures/SwaggerServiceTest/documentation/invalid_format__response__invalid_items.json @@ -0,0 +1,256 @@ +{ + "openapi": "3.1.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore 2.0" + }, + "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": { + "/users/{id}": { + "post": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "produces": [ + "application/xml", + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Pet" + } + } + }, + "400": { + "description": "Invalid status value" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + } + }, + "securityDefinitions": { + "petstore_auth": { + "type": "oauth2", + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "flow": "implicit", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + }, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + }, + "definitions": { + "Order": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "petId": { + "type": "integer", + "format": "int64" + }, + "quantity": { + "type": "integer", + "format": "int32" + }, + "shipDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status", + "enum": [ + "placed", + "approved", + "delivered" + ] + }, + "complete": { + "type": "boolean", + "default": false + } + }, + "xml": { + "name": "Order" + } + }, + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Category" + } + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "username": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status" + } + }, + "xml": { + "name": "User" + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Tag" + } + }, + "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" + } + } + } +} From fb1853321d168ef996c8e529d1c5cbacc946c103 Mon Sep 17 00:00:00 2001 From: DenTray Date: Mon, 7 Oct 2024 12:51:35 +0600 Subject: [PATCH 8/8] Update src/Services/SwaggerService.php --- src/Services/SwaggerService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index 5ad941f8..a9f12fd2 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -244,7 +244,7 @@ protected function getPathParams(): array 'name' => $key, 'description' => $this->generatePathDescription($key), 'required' => true, - "schema" => [ + 'schema' => [ 'type' => 'string' ] ];