dedoc / scramble

Modern Laravel OpenAPI (Swagger) documentation generator. No PHPDoc annotations required.
https://scramble.dedoc.co/
MIT License
1.18k stars 112 forks source link

Issue with Overriding AnonymousResourceCollectionTypeToSchema Using Custom Extension #553

Closed jaimyborgman closed 1 week ago

jaimyborgman commented 1 week ago

@romalytvynenko

I am working with a CustomAnonymousResourceCollectionTypeToSchema class that is meant to override the built-in AnonymousResourceCollectionTypeToSchema. I’ve registered it within the scramble.php config, and when debugging, I can confirm it’s being invoked as expected.

However, it seems that the built-in AnonymousResourceCollectionTypeToSchema still overrides the final outcome, which brings me back to the default behavior.

What I’m trying to achieve is overriding the AnonymousResourceCollectionTypeToSchema to customize the $wrapKey property. Currently, I’m defining $wrapKey = Merchant::class within my Resource object, which works fine for Resource::make(). But when using Resource::collection(), it falls back to the default behavior of AnonymousResourceCollectionTypeToSchema.

Is there a way to fully override the wrapper behavior in this case, or customize the $wrapKey specifically for collections? Any guidance would be appreciated!

romalytvynenko commented 1 week ago

@jaimyborgman which Scramble version are you using? In the latest version this issue with wrap key was fixed.

Regarding extensions, the issue is known and I'm on it

jaimyborgman commented 1 week ago

@romalytvynenko thanks for letting me know that the issue is known; will await a fix for now I’m overriding it within the service provider.

I’m using the latest version 😁

romalytvynenko commented 1 week ago

@jaimyborgman So you're using the latest version and wrap key is not correct?

jaimyborgman commented 1 week ago

@romalytvynenko well the wrap key is working since it is taking it from the Resource::$wrap except that I’m using a custom version there instead of defining the wrap key as for instance “product” I’m using Product::class which will be converted to “product” or “products” later on. But with the current class in scramble this results in a “Namespaced//Product” key instead

romalytvynenko commented 1 week ago

@jaimyborgman okay, if the issue is extension ordering, I'm closing the issue due to the problem being known (https://github.com/dedoc/scramble/pull/498)