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

API v4 basePath configuration #428

Open
lutangar opened this issue Jul 28, 2021 · 0 comments
Open

API v4 basePath configuration #428

lutangar opened this issue Jul 28, 2021 · 0 comments

Comments

@lutangar
Copy link
Member

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.

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

1 participant