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

OpenApi export command does not work #5567

Closed
Univalgo opened this issue Apr 25, 2023 · 4 comments
Closed

OpenApi export command does not work #5567

Univalgo opened this issue Apr 25, 2023 · 4 comments

Comments

@Univalgo
Copy link

Univalgo commented Apr 25, 2023

API Platform version(s) affected: 3.1.9

Description
The autoloader expected class "ApiPlatform\Symfony\Bundle\Command\OpenApiCommand" to be defined in file "/app/vendor/composer/../api-platform/core/src/Symfony/Bundle/Command/OpenA
piCommand.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

How to reproduce
Just install symfony 6.2 with api-platform >3.1.7 and try to run the command api:openapi:export

@aharabara
Copy link

aharabara commented Apr 25, 2023

I have the same issue when I try to run php ./bin/console debug (which should fail with a list of possible autocompletes):

 The autoloader expected class "ApiPlatform\Symfony\Bundle\Command\OpenApiCommand" to be defined in file "/srv/api/vendor/composer/../api-platform/core/src/Symfony/Bundle/Command/OpenApiCommand.php".  
   The file was found but the class was not in it, the class name or namespace probably has a typo. 

I did a small research and seems that it is related to this construction :

class_exists(\ApiPlatform\OpenApi\Command\OpenApiCommand::class);

if (false) {
    final class OpenApiCommand extends \ApiPlatform\OpenApi\Command\OpenApiCommand
    {
    }
}

in vendor/api-platform/core/src/Symfony/Bundle/Command/OpenApiCommand.php file. I saw a similar thing solved in changelog of v3.1.9 and I have a feeling it is related to some sort of a build tool that replaced
if(!class_exists(...)){...}
with
class_exists(...); if(false){...}

@Pierstoval
Copy link

Pierstoval commented Apr 25, 2023

I made a PR to fix that #5568 , not sure whether "this is the way" ™️ but at least it works for me

@aharabara
Copy link

Taking into consideration changes in version 3.1.9 there is a high chance you will have to remove the if (false) statement.

@bogdan-dubyk
Copy link

bogdan-dubyk commented Apr 26, 2023

@Pierstoval I tried to make your changes locally but now I have another issue

  Warning: Cannot declare class ApiPlatform\Symfony\Bundle\Command\OpenApiCommand, because the name is already in use  

while I running any other CLI command

soyuka added a commit to soyuka/core that referenced this issue Apr 28, 2023
soyuka added a commit that referenced this issue Apr 28, 2023
@soyuka soyuka closed this as completed Apr 28, 2023
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

Successfully merging a pull request may close this issue.

5 participants