As far as I know, there is no mechanism in the API Platform that can handle multiple documentation. Although installing independently NelmioApiDocBundle can be a workaround for you. If configured properly you can create areas that are separate from API Platform autogenerated documentation.
There is only one problem with this solution. If you are using API Platform for configured areas documentation is duplicated. Endpoints that are supposed to be only in doc bundle are also in swagger generated by API Platform. To fix that problem you can decorate API platform swagger normalizer:
final class HideCoreDocsNormalizer implements NormalizerInterface {
private const DOCS_PATHS = [
'/api/foo/docs',
'/api/foo/docs.json',
];
public function __construct(
private RequestStack $requestStack,
) {
}
/**
* @param Documentation $object
* @param array<string, mixed> $context
*
* @return mixed[]|string|int|float|bool|null
*/
public function normalize($object, $format = null, array $context = []): mixed
{
return null;
}
public function supportsNormalization($data, $format = null): bool
{
if ($this->requestStack->getCurrentRequest() === null) {
return false;
}
return in_array($this->requestStack->getCurrentRequest()->getPathInfo(), self::DOCS_PATHS);
}
}
And in configuration file:
Foo\Bar\Serializer\HideDocsNormalizer:
decorates: 'api_platform.swagger.normalizer.api_gateway'
arguments: [ '@request_stack' ]
autoconfigure: false