dis-moi / dis-moi/backend

API v4 basePath configuration

Open
#428 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Description

The API prefix is currenlty configured via route prefix in `config/routes/api_platform.yaml`:
```
api_platform:
resource: .
type: api_platform
prefix: /v4
```

The problem is when dumping the OpenAPI definition :
```
docker-compose exec php bin/console api:openapi:export --yaml --output=oas.yaml
````

The server `baseUrl` is still set to `/`:
```
servers:
-
url: /
description: ''
paths:
'/v4/contributors/{id}':
```

We can manually set the `baseUrl` in a custom `OpenApiFactory`:
```
$context[ApiPlatformOpenApiFactory::BASE_URL] = '/v4/';
```
But this doesn't get rid of the prefix on the paths...

Ideally there should be a way to configure a `baseUrl` in ApiPlatform configuration and this `baseUrl` would then be used in the OpenAPI generation.

This would result in the following:
```
servers:
-
url: /v4/
description: ''
paths:
'/contributors/{id}':
```

Maybe if there was a way to override the `api_platform.router` we could set the `router.request_context.base_url` to `v4` there.

Contributor guide

Open the contributing guide

Research direction

Start with config/routes/api_platform.yaml and run the documented docker-compose OpenAPI export to reproduce the current server URL and prefixed paths. Review the API Platform configuration and router integration described in the issue, then verify that a configured base URL produces /v4/ as the server URL and removes /v4 from the generated paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.