fix: issue with extensions being overwritten by built-in extensions
This is a fix for this issue/question https://github.com/dedoc/scramble/discussions/442
The order of the types of extensions caused the issue. All the other extension types are merged by putting the custom ones at the end of the array. Still, in the case of TypeTransformer it was at the beginning which caused custom extensions to be overridden by the built-in extensions.
Thanks for so much for the PR!
We have the same issue and it would be great if this would be released. There were already two PRs (#361 and #347) that did the same, but they were closed. Let's hope it works out this time 🙏
I think the real issue we're having, is that we can't choose exactly when our extensions are being used. I'm thinking a priority property, a before/after hook, or some resolution logic to replace one of the default extensions would be ideal. In my case, I still want the EnumToSchema, JsonResourceTypeToSchema, ModelToSchema, and EloquentCollectionToSchema to be called before my PaginatedResourceCollectionTypeToSchema.
The simplest solution would be for the package classes to have public int $priority = 10; // increments of 10, allowing us to put 9 (or more if same priority won't break functionality) extensions in between each of the defaults. Custom extensions would have a default priority of 1, so the existing behavior is unchanged.
If no one else implements this, I'll start working on it this weekend.
@romalytvynenko Would this be an acceptable solution?
@hn-seoai this is indeed something to be thought off. Please wait before working on it, as I'm still thinking about the solution
@korridor @hn-seoai @horlarme Just to be clear, I agree this is the real issue and needs to be addressed. Thanks for raising the issue
Closing this PR, as the issue is fixed by this one: https://github.com/dedoc/scramble/pull/570
Thanks!