Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect path in config checking #105

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Exceptions/EmptyContactEmailException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class EmptyContactEmailException extends Exception
{
public function __construct()
{
parent::__construct('Please fill the `contact.email` field in the app-doc.php config file.');
parent::__construct('Please fill the `info.contact.email` field in the app-doc.php config file.');
}
}
5 changes: 3 additions & 2 deletions src/Services/SwaggerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use RonasIT\Support\AutoDoc\Exceptions\InvalidDriverClassException;
use RonasIT\Support\AutoDoc\Exceptions\LegacyConfigException;
use RonasIT\Support\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerSpecException;
use RonasIT\Support\AutoDoc\Exceptions\SpecValidation\InvalidSwaggerVersionException;
use RonasIT\Support\AutoDoc\Exceptions\SwaggerDriverClassNotFoundException;
use RonasIT\Support\AutoDoc\Exceptions\WrongSecurityConfigException;
use RonasIT\Support\AutoDoc\Interfaces\SwaggerDriverInterface;
Expand Down Expand Up @@ -112,7 +111,9 @@ protected function setDriver()

protected function generateEmptyData(): array
{
if (!Arr::get($this->config, 'contact.email')) {
// client must enter at least `contact.email` to generate a default `info` block
// otherwise an exception will be called
if (!empty($this->config['info']) && !Arr::get($this->config, 'info.contact.email')) {
throw new EmptyContactEmailException();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/SwaggerSpecValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ protected function validateParameterType(array $param, array $operation, string
break;
default:
$requiredFields = ['type'];
$validTypes = self::PRIMITIVE_TYPES;
$validTypes = array_merge(self::PRIMITIVE_TYPES, ['object']);
}

$this->validateFieldsPresent($requiredFields, $paramId);
Expand Down
2 changes: 1 addition & 1 deletion tests/SwaggerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function testConstructorInvalidTmpData(string $tmpDoc, string $exception,

public function testEmptyContactEmail()
{
config(['auto-doc.contact.email' => null]);
config(['auto-doc.info.contact.email' => null]);

$this->expectException(EmptyContactEmailException::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setUp(): void
{
parent::setUp();

config(['auto-doc.contact.email' => '[email protected]']);
config(['auto-doc.info.contact.email' => '[email protected]']);
}

public function tearDown(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"title": "Name of Your Application",
"termsOfService": "",
"contact": {
"email": null
"email": "[email protected]"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"title": "Name of Your Application",
"termsOfService": "",
"contact": {
"email": null
"email": "[email protected]"
}
},
"securityDefinitions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"title": "Name of Your Application",
"termsOfService": "",
"contact": {
"email": null
"email": "[email protected]"
}
},
"securityDefinitions": {
Expand Down