Skip to content

Commit

Permalink
Merge pull request #318 from vtsykun/fix-paths
Browse files Browse the repository at this point in the history
Fix path prefix
  • Loading branch information
vtsykun authored Mar 2, 2025
2 parents f774ed1 + 72ad991 commit 2ec5cac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/Service/SwaggerDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

namespace Packeton\Service;

use Packeton\Trait\RequestContextTrait;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Yaml\Yaml;

class SwaggerDumper
{
use RequestContextTrait;

public function __construct(
protected string $swaggerDocsDir,
protected RequestContext $requestContext,
) {
}

Expand Down Expand Up @@ -41,8 +46,8 @@ public function dump(array $replacement = []): array

protected function wrapResponse(array $spec): array
{
$paths = $spec['paths'] ?? [];
foreach ($paths as $path => $resources) {
$paths = [];
foreach ($spec['paths'] ?? [] as $path => $resources) {
if (!is_array($resources)) {
continue;
}
Expand All @@ -66,6 +71,8 @@ protected function wrapResponse(array $spec): array
}
$resources[$name] = $resource;
}

$path = $this->generateUrl($path);
$paths[$path] = $resources;
}
$spec['paths'] = $paths;
Expand Down
2 changes: 1 addition & 1 deletion templates/about/about.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>
<p>You can find the source on <a href="https://github.com/vtsykun/packeton">GitHub</a>.</p>

{% set url = app.request.getSchemeAndHttpHost() %}
{% set url = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl() %}
{% set apiToken = get_api_token(app.user) %}
{% set shortApiToken = get_api_token(app.user, false)|default('<token>') %}

Expand Down
2 changes: 1 addition & 1 deletion templates/apidoc/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li><a href="#swagger-ui">Swagger</a></li>
</ul>
{% set apiToken = get_api_token(app.user)|default('<api_token>') %}
{% set packagist_url = app.request.getSchemeAndHttpHost() %}
{% set packagist_url = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl() %}

<section class="col-d-12">
<h3 id="list-packages">{{ 'api_doc.listing_names'|trans }}</h3>
Expand Down

0 comments on commit 2ec5cac

Please sign in to comment.