-
Notifications
You must be signed in to change notification settings - Fork 2
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
Suggest list<TYPE>
over array<TYPE>
and TYPE[]
#33
Comments
@nickvergessen do you think we should also suggest |
Making people change their working production code is not the best idea. Also just for the record because the title is irritating. Not every array is a list. But every list is an array. In a lot of cases docs are basically lying and claim |
If there are a gaps in the keys then the array should be specified as |
I'd make it a warning for now, but I think at some point this should be enforced to prevent bugs. |
Yes, but that is not what most apps have at the moment. And if they would just add |
Syntax |
But |
No, Reading https://psalm.dev/docs/annotating_code/type_syntax/array_types/ at least it’s clear |
After reading that I feel like we might want to discourage |
I’m hesitant. So yeah I don’t know. For ocs API yes it makes sense to encourage |
The problem I see is that this could result in different JSON outputs. It could either be an array or an object, but currently we just assume it is always an array. Now this doesn't seem to be true so it should be fixed, but that would get super ugly and I've never encountered a problem with it so far.
So basically a recursive object? Are you a facing a limitation of openapi-extractor or psalm? To my knowledge psalm doesn't allow any self-referencing/recursive types, so I don't know how to achieve what you describe. Please let me know if I can help you. |
Yeah I meant for PHP usage, not for the JSON API. For the API I think it makes sense to use and enforce
Yes. I think it is a psalm limitation. |
Yeah OpenAPI/JSON schema can describe recursive types, but there is no way we can generate them due to the psalm limitation. |
We have to forbid anything that is equivalent to @come-nc @nickvergessen does this make sense to you? I fear this will have quite some impact and necessary changes (so it should be a warning at first), but it is necessary to fix these problems to ensure the specifications match any data that could possibly returned. |
list<...>
over array<...>
list<TYPE>
over array<TYPE>
and TYPE[]
We need to properly communicate this. Most people that use
necessary doc changes, most functionality should be "fine" |
Functionality yes, but I already started adapting the server to these changes and it causes a lot of changes deeper in the code where the typing is already wrong. |
we could have a commit/branch in this repo, then people can checkout the commit locally and run it |
Yeah that's what I meant with "make a draft PR". I wasn't specific enough on which repo this would be. |
See #168 |
The
array
type can be dangerous in some situations where you definitely only want alist
.The text was updated successfully, but these errors were encountered: