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

Non serializable configuration when using global security #10

Open
marezelej opened this issue Apr 14, 2020 · 9 comments
Open

Non serializable configuration when using global security #10

marezelej opened this issue Apr 14, 2020 · 9 comments

Comments

@marezelej
Copy link

marezelej commented Apr 14, 2020

When configuring global security it is not posible to use config:cache command as it breaks with the "Your configuration files are not serializable." exception.
At config/openapi.php:
'security' => [ GoldSpecDigital\ObjectOrientedOAS\Objects\SecurityRequirement::create()->securityScheme('oauth2'), ],
Exception:
image

I solved the issue using an array for the security specification, but had to override the GoldSpecDigital\ObjectOrientedOAS\OpenApi class.

@matthew-inamdar
Copy link

@vyuldashev could this be solved by providing custom __unserialize() and __wakeup() methods for each object?

@vyuldashev
Copy link
Owner

vyuldashev commented Apr 14, 2020

@matthew-inamdar I guess so. Probably in BaseObject would be enough.

@marezelej
Copy link
Author

Method __get_state should be added too.

@marezelej
Copy link
Author

I added by extending SecurityRequirement class and got same problem with GoldSpecDigital\ObjectOrientedOAS\Utilities\Extensions class.

@andrewminion-luminfire
Copy link
Contributor

@marezelej Did you get this working? I’m running into the same problems.

@marezelej
Copy link
Author

marezelej commented Jul 11, 2020

@andrewminion-luminfire yes...
I ovewritten OpenApi class using composer. There, changed security method signature to allow passing an array as security configuration.
Composer.json override:
image
OpenApi.php override:
image
openapi.php security configuration:
image

It is not the best solution but worked for me.

@andrewminion-luminfire
Copy link
Contributor

Thanks @marezelej!

@macbookandrew
Copy link
Contributor

goldspecdigital/oooas#56 should fix this

@abordage
Copy link

abordage commented Feb 2, 2024

Solution based on https://github.com/symplify/vendor-patches:

  1. install symplify/vendor-patches

  2. update config/openapi.php

'security' => [
    [
        'BearerToken' => []
    ],
],
  1. copy vendor/goldspecdigital/oooas/src/OpenApi.php to vendor/goldspecdigital/oooas/src/OpenApi.php.old and update security method in vendor/goldspecdigital/oooas/src/OpenApi.php
 * @param array $security
 * @return static
 */
public function security($security): self
{
    $instance = clone $this;

    $instance->security = [$security] ?: null;

    return $instance;
}
  1. run vendor/bin/vendor-patches generate
  2. run composer update
  3. check php artisan optimize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants