-
Notifications
You must be signed in to change notification settings - Fork 16
...PropertyProxy::getProperty(): Return value must be of type ...PropertyInterface, null returned in #65
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
Comments
Hi, thanks for the report. The The main issue is caused by the combination of recursion and the This will actually not be an easy fix. I've to think about a solution on how to change the resolving. |
For the pattern match, you're right, you only need to escape one character, About the recursion, I don't know if this helps, but I solved similar problems in the past by first registering entries and then actually processing them - very similar to what you did in the comment you provided. Unfortunately I don't know enough about this scenario to suggest a more specific approach, sorry. |
Exactly, the fix for pattern properties is identical to string properties with a pattern (https://github.com/wol-soft/php-json-schema-model-generator/blob/master/src/PropertyProcessor/Property/StringProcessor.php#L61). Registering things and resolving them later is also used in this library (eg. the rendering of the code is executed after setting up all internal structures). The mechanic to resolve the issue will be similar. But as mentioned above, I've to think about the exact implementation approach. |
Add onResolved callback to properties to execute further post-processing of the property only after the property has been created completely. Otherwise, the property might redirect to null causing the generation process to crash. Compositions for example use generated properties to enrich the base model the composition belongs to. This process must be delayed until the properties are completely set up (an incomplete property might occur due to recursion). Consequently now the composition uses a callback mechanism to delay the process until all recursions are resolved.
Hi @uuf6429, I've managed to (hopefully 😄) locate all places where the nested recursion causes issues like the original I've set up a branch https://github.com/wol-soft/php-json-schema-model-generator/tree/65-recursive-reference-resolving with the current state. I need to add a lot of tests in this section of recursions (the provided schema seems to be like a final boss for the library). Currently with the branch all existing tests are passing and the provided Do you have any data matching the schema for some manual testing? For the automated tests I'll strip the schema down to the cases causing the issues. Sorry for the long response delay. |
Add onResolved callback to validators to execute further post-processing of the validator and properties holding the validator only after the validator has been created completely. This is required as a validator might hold a nested property to execute the validation. This nested property might be a PropertyProxy due to recursion which might cause a crash of the generation process if the property hasn't been created completely before post-processing the property and the validator.
Uh oh!
There was an error while loading. Please reload this page.
Note that the function return type was defined as non-null and, as you can see in the debugger, the specific key being looked up points to a null.
My suspicion (without digging deep into the code) is that the recursive declaration (line 530 of the schema) might be causing the null?
Describe the bug
Attempt to return null on a non-null return during generation.
Expected behavior
Generation should have succeeded.
Schema
https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json
Version:
0.23 (generator) / 0.18 (interfaces)
Additionally, the
patternProperties
regex check inBaseProcessor
line 171 is triggering a failure for pattern^/(html|css|js)/[^/\n\r]+$
, which to me looks fine, but maybe I'm missing the purpose of the check.The text was updated successfully, but these errors were encountered: