janephp icon indicating copy to clipboard operation
janephp copied to clipboard

Missing getInitialized function in open-api-common model class generator

Open nickvanderzwet opened this issue 2 years ago • 4 comments

Jane version(s) affected: 7.4.1

Description

Fatal error: Uncaught Error: Call to undefined method Jane\Component\OpenApiCommon\Generator\ModelGenerator::getInitialized() in /var/www/sources/vendor/jane-php/open-api-common/Generator/Model/ClassGenerator.php:46
Stack trace:
#0 /var/www/sources/vendor/jane-php/open-api-common/Generator/ModelGenerator.php(35): Jane\Component\OpenApiCommon\Generator\ModelGenerator->createModel('Error', Array, Array, true, false, NULL)
#1 /var/www/sources/vendor/jane-php/json-schema/Generator/ModelGenerator.php(73): Jane\Component\OpenApiCommon\Generator\ModelGenerator->doCreateModel(Object(Jane\Component\OpenApiCommon\Guesser\Guess\ClassGuess), Array, Array)
#2 /var/www/sources/vendor/jane-php/json-schema/Generator/ChainGenerator.php(28): Jane\Component\JsonSchema\Generator\ModelGenerator->generate(Object(Jane\Component\OpenApiCommon\Registry\Schema), '', Object(Jane\Component\JsonSchema\Generator\Context\Context))
#3 /var/www/sources/vendor/jane-php/open-api-common/Console/Command/GenerateCommand.php(61): Jane\Component\JsonSchema\Gene in /var/www/sources/vendor/jane-php/open-api-common/Generator/Model/ClassGenerator.php on line 46

How to reproduce
Run bin/jane-openapi generate with OpenApi 3.0 specification

Possible Solution https://github.com/janephp/janephp/blob/next/src/Component/OpenApiCommon/Generator/Model/ClassGenerator.php#L46 has no getInitialized function.

Class seems a lot like https://github.com/janephp/janephp/blob/next/src/Component/JsonSchema/Generator/Model/ClassGenerator.php which has the function.

nickvanderzwet avatar Jan 30 '23 13:01 nickvanderzwet

Thanks for your issue, it seems this was missed during the PR I made, I'll try to fix it quickly sorry.

Korbeil avatar Feb 01 '23 12:02 Korbeil

Could you share me the output of the composer show jane-php/* command please ? I think you have miss-matching versions of Jane cause I can't reproduce your issue.

Korbeil avatar Feb 01 '23 12:02 Korbeil

@Korbeil, I have the same issue in a Symfony 4.4 environment. Here is the output, thank you:

jane-php/json-schema v7.2.5 Generate a serializable / deserializable object model given a json schema jane-php/json-schema-runtime v7.5.0 Jane runtime Library jane-php/open-api-3 v7.5.0 Generate a PHP Client API (PSR7/PSR18 compatible) given a OpenApi 3.x specification jane-php/open-api-bundle v7.5.0 Jane OpenApi Symfony Bundle jane-php/open-api-common v7.5.0 Utility for OpenApi 2/3 generators jane-php/open-api-runtime v7.5.0 Jane OpenAPI Runtime Library, dependencies and utility class for a library generated by jane/openapi

In addition, I think it is not related but "config/packages/open-api.yaml" was not generated as specified in the doc.

alexxandres avatar May 10 '23 16:05 alexxandres

Here's my output with the same issue :

jane-php/json-schema         v7.2.5 Generate a serializable / deserializable object model given a json schema
jane-php/json-schema-runtime v7.5.5 Jane runtime Library
jane-php/open-api-3          v7.5.4 Generate a PHP Client API (PSR7/PSR18 compatible) given a OpenApi 3.x specification
jane-php/open-api-common     v7.5.5 Utility for OpenApi 2/3 generators
jane-php/open-api-runtime    v7.5.5 Jane OpenAPI Runtime Library, dependencies and utility class for a library generated by jane/openapi

Reproducer information :

My Jane\Component\JsonSchema\Generator\Model\ClassGenerator doesn't contains getInitialized() for whatever reason. Still digging.

json-schema v7.2.5 seems to be the issue. 7.4 introduced this function and should have a BC on other components. 7.3.0 dropped symfony 4 support with validator needing 5.0 https://github.com/janephp/json-schema/compare/v7.2.5...v7.3.0

Workaround :

"conflict": {
    "jane-php/json-schema-runtime": ">7.2.5",
    "jane-php/open-api-common": ">7.2.5",
    "jane-php/open-api-runtime": ">7.2.5"
}

vasilvestre avatar Apr 03 '24 11:04 vasilvestre