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

Uncaught Error: Call to undefined method Jane\Component\JsonSchemaRuntime\Reference::getDefault() in NonBodyParameterGenerator.php:164 #803

Open
BusterNeece opened this issue May 1, 2024 · 0 comments
Labels

Comments

@BusterNeece
Copy link

Jane version(s) affected: 7.6.x

Description
When attempting to generate an API client from the OpenAPI spec document linked below, this fatal error is triggered and generation can't continue.

How to reproduce
This triggers with this OpenAPI 3.0 spec document: https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml

Stack trace

Fatal error: Uncaught Error: Call to undefined method Jane\Component\JsonSchemaRuntime\Reference::getDefault() in /var/app/www/vendor/jane-php/open-api-3/Generator/Parameter/NonBodyParameterGenerator.php:164
Stack trace:
#0 /var/app/www/vendor/jane-php/open-api-3/Generator/Parameter/NonBodyParameterGenerator.php(111): Jane\Component\OpenApi3\Generator\Parameter\NonBodyParameterGenerator->getDefaultAsExpr(Object(Jane\Component\OpenApi3\JsonSchema\Model\Parameter))
#1 /var/app/www/vendor/jane-php/open-api-3/Generator/Endpoint/GetGetOptionsResolverTrait.php(52): Jane\Component\OpenApi3\Generator\Parameter\NonBodyParameterGenerator->generateOptionsResolverStatements(Object(PhpParser\Node\Expr\Variable), Array, Array)
#2 /var/app/www/vendor/jane-php/open-api-3/Generator/EndpointGenerator.php(98): Jane\Component\OpenApi3\Generator\EndpointGenerator->getOptionsResolverMethod(Object(Jane\Component\OpenApiCommon\Guesser\Guess\OperationGuess), 'query', 'getQueryOptions...', Object(Jane\Component\OpenApi3\Guesser\GuessClass), Object(Jane\Component\OpenApi3\Generator\Parameter\NonBodyParameterGenerator), Array, Array)
#3 /var/app/www/vendor/jane-php/open-api-common/Generator/OperationGenerator.php(37): Jane\Component\OpenApi3\Generator\EndpointGenerator->createEndpointClass(Object(Jane\Component\OpenApiCommon\Guesser\Guess\OperationGuess), Object(Jane\Component\JsonSchema\Generator\Context\Context))
#4 /var/app/www/vendor/jane-php/open-api-common/Generator/ClientGenerator.php(38): Jane\Component\OpenApiCommon\Generator\OperationGenerator->createOperation('searchAvatars', Object(Jane\Component\OpenApiCommon\Guesser\Guess\OperationGuess), Object(Jane\Component\JsonSchema\Generator\Context\Context))
#5 /var/app/www/vendor/jane-php/json-schema/Generator/ChainGenerator.php(28): Jane\Component\OpenApiCommon\Generator\ClientGenerator->generate(Object(Jane\Component\OpenApiCommon\Registry\Schema), '', Object(Jane\Component\JsonSchema\Generator\Context\Context))
#6 /var/app/www/vendor/jane-php/open-api-common/Console/Command/GenerateCommand.php(61): Jane\Component\JsonSchema\Generator\ChainGenerator->generate(Object(Jane\Component\OpenApiCommon\Registry\Registry))
#7 /var/app/www/vendor/symfony/console/Command/Command.php(279): Jane\Component\OpenApiCommon\Console\Command\GenerateCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/app/www/vendor/symfony/console/Application.php(1031): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/app/www/vendor/symfony/console/Application.php(318): Symfony\Component\Console\Application->doRunCommand(Object(Jane\Component\OpenApiCommon\Console\Command\GenerateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/app/www/vendor/symfony/console/Application.php(169): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/app/www/vendor/jane-php/open-api-common/bin/jane-openapi(24): Symfony\Component\Console\Application->run()
#12 /var/app/www/vendor/bin/jane-openapi(119): include('/var/app/www/ve...')
#13 {main}
  thrown in /var/app/www/vendor/jane-php/open-api-3/Generator/Parameter/NonBodyParameterGenerator.php on line 164

Additional context
I strongly suspect this is related to #299 as it's the exact same error being triggered on the exact same file. Unfortunately, it looks like the fix from that issue didn't also fix this issue.

It's possible that the OpenAPI spec YAML is malformed in some way, but I can't immediately identify what's causing the problem with just the error given by JanePHP.

@BusterNeece BusterNeece added the bug label May 1, 2024
@BusterNeece BusterNeece changed the title Fatal error: Uncaught Error: Call to undefined method Jane\Component\JsonSchemaRuntime\Reference::getDefault() in /vendor/jane-php/open-api-3/Generator/Parameter/NonBodyParameterGenerator.php:164 Uncaught Error: Call to undefined method Jane\Component\JsonSchemaRuntime\Reference::getDefault() in NonBodyParameterGenerator.php:164 May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant