Skip to content

Commit

Permalink
Set version to openapi automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Sep 7, 2023
1 parent 06873cc commit 5be6e4d
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 35 deletions.
1 change: 0 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
\Movary\HttpController\Web\CreateUserController::class => DI\factory([Factory::class, 'createCreateUserController']),
\Movary\HttpController\Web\JobController::class => DI\factory([Factory::class, 'createJobController']),
\Movary\HttpController\Web\LandingPageController::class => DI\factory([Factory::class, 'createLandingPageController']),
\Movary\HttpController\Web\SettingsController::class => DI\factory([Factory::class, 'createSettingsController']),
\Movary\HttpController\Web\Middleware\ServerHasRegistrationEnabled::class => DI\factory([Factory::class, 'createMiddlewareServerHasRegistrationEnabled']),
\Movary\ValueObject\Http\Request::class => DI\factory([Factory::class, 'createCurrentHttpRequest']),
\Movary\Command\CreatePublicStorageLink::class => DI\factory([Factory::class, 'createCreatePublicStorageLink']),
Expand Down
6 changes: 1 addition & 5 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"title": "Movary",
"version": ""
},
"servers": [
{
"url": "\/api"
}
],
"servers": [],
"paths": {
"\/users\/{username}\/history": {
"get": {
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Jellyfin/JellyfinClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function convertException(\Exception $e, Url $url) : \Exception
private function generateHeaders(?JellyfinAccessToken $jellyfinAccessToken = null) : array
{
$appName = $this->serverSettings->getJellyfinAppName();
$appVersion = $this->serverSettings->getApplicationVersion() ?? 'dev';
$appVersion = $this->serverSettings->getApplicationVersion();
$deviceId = $this->serverSettings->requireJellyfinDeviceId();

$authorizationString = 'MediaBrowser Client ="' . $appName . '", Device ="' . php_uname('s') . '", Version="' . $appVersion . '", DeviceId="' . $deviceId . '"';
Expand Down
24 changes: 0 additions & 24 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,6 @@ public static function createOpenApiController(ContainerInterface $container) :
);
}

public static function createSettingsController(ContainerInterface $container, Config $config) : SettingsController
{
return new SettingsController(
$container->get(Twig\Environment::class),
$container->get(Authentication::class),
$container->get(TwoFactorAuthenticationApi::class),
$container->get(UserApi::class),
$container->get(MovieApi::class),
$container->get(GithubApi::class),
$container->get(PlexApi::class),
$container->get(SessionWrapper::class),
$container->get(LetterboxdExporter::class),
$container->get(TraktApi::class),
$container->get(JellyfinApi::class),
$container->get(ServerSettings::class),
$container->get(WebhookUrlBuilder::class),
$container->get(JobQueueApi::class),
$container->get(DashboardFactory::class),
$container->get(EmailService::class),
$container->get(Tmdb\Cache\TmdbIsoCountryCache::class),
self::getApplicationVersion($config),
);
}

public static function createTmdbApiClient(ContainerInterface $container) : Tmdb\TmdbClient
{
return new Tmdb\TmdbClient(
Expand Down
1 change: 1 addition & 0 deletions src/HttpController/Api/OpenApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getSchema() : Response

$openapiData['info']['version'] = $this->serverSettings->getApplicationVersion();

$openapiData['servers'][0]['url'] = '/api';
$applicationUrl = $this->serverSettings->getApplicationUrl();
if ($applicationUrl !== null) {
$openapiData['servers'][0]['url'] = trim($applicationUrl, '/') . '/api';
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Web/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function __construct(
private readonly DashboardFactory $dashboardFactory,
private readonly EmailService $emailService,
private readonly TmdbIsoCountryCache $countryCache,
private readonly string $currentApplicationVersion,
) {
}

Expand Down Expand Up @@ -152,7 +151,7 @@ public function renderAppPage() : Response
return Response::create(
StatusCode::createOk(),
$this->twig->render('page/settings-app.html.twig', [
'currentApplicationVersion' => $this->currentApplicationVersion,
'currentApplicationVersion' => $this->serverSettings->getApplicationVersion(),
'latestRelease' => $this->githubApi->fetchLatestMovaryRelease(),
'timeZone' => date_default_timezone_get(),
]),
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ServerSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function getApplicationUrl() : ?string
return $this->getByKey(self::APPLICATION_URL);
}

public function getApplicationVersion() : ?string
public function getApplicationVersion() : string
{
return $this->getByKey(self::APPLICATION_VERSION);
return $this->getByKey(self::APPLICATION_VERSION) ?? 'unknown';
}

public function getFromAddress() : ?string
Expand Down

0 comments on commit 5be6e4d

Please sign in to comment.