88use Illuminate \Support \Str ;
99use ReflectionClass ;
1010use Illuminate \Http \Request ;
11+ use RonasIT \Support \AutoDoc \Exceptions \LegacyConfigException ;
1112use RonasIT \Support \AutoDoc \Exceptions \WrongSecurityConfigException ;
1213use RonasIT \Support \AutoDoc \Traits \GetDependenciesTrait ;
1314use Symfony \Component \HttpFoundation \Response ;
@@ -38,7 +39,7 @@ class SwaggerService
3839
3940 public function __construct (Container $ container )
4041 {
41- $ this ->config = config ( ' auto-doc ' );
42+ $ this ->initConfig ( );
4243
4344 $ this ->setDriver ();
4445
@@ -57,6 +58,29 @@ public function __construct(Container $container)
5758 }
5859 }
5960
61+ protected function initConfig ()
62+ {
63+ $ this ->config = config ('auto-doc ' );
64+
65+ $ version = Arr::get ($ this ->config , 'config_version ' );
66+
67+ if (empty ($ version )) {
68+ throw new LegacyConfigException ();
69+ }
70+
71+ $ packageConfigs = require __DIR__ . '/../../config/auto-doc.php ' ;
72+
73+ $ major = Str::before ($ version , '. ' );
74+ $ minor = Str::after ($ version , '. ' );
75+
76+ $ actualMajor = Str::before ($ packageConfigs ['config_version ' ], '. ' );
77+ $ actualMinor = Str::after ($ packageConfigs ['config_version ' ], '. ' );
78+
79+ if ($ actualMajor > $ major || $ actualMinor > $ minor ) {
80+ throw new LegacyConfigException ();
81+ }
82+ }
83+
6084 protected function setDriver ()
6185 {
6286 $ driver = $ this ->config ['driver ' ];
0 commit comments