fluent-json-schema icon indicating copy to clipboard operation
fluent-json-schema copied to clipboard

fix: ObjectSchema.extend returns a schema instance

Open deepaknf opened this issue 1 year ago • 3 comments

Summary

This PR addresses the issue https://github.com/fastify/fluent-json-schema/issues/249 where ObjectSchema.extend Does not return a schema instance. The fix makes it return the schema.

Checklist

deepaknf avatar Sep 05 '24 13:09 deepaknf

It seems it was intentionally not returning a Schema instance before this. Do we know why it was like that in the first place?

Looking at where that was originally changed (to not return Schema) I see this PR & issue with some explanation but I don't understand the context well enough to say if it's still valid:

https://github.com/fastify/fluent-json-schema/pull/69 https://github.com/fastify/fluent-json-schema/issues/65

bencoder avatar Sep 05 '24 13:09 bencoder

@aboutlo I don't suppose you can help us understand this? It looks like you were heavily involved in the previous issues that @bencoder listed. Thanks :)

kieranswhite avatar Sep 05 '24 14:09 kieranswhite

I don't think we can safely merge this change, precisely because, as observed, this behavior is intentional. The change is straightforward, but before we even change anything, we need to understand why the current behavior was intentionally implemented in this way, and the explanation lies in the PRs linked by @bencoder above. So, please have a look at the whole history before deciding what to do with this issue. A viable option is to close it as it works as designed, but I would consider giving another look at the original motivations behind this behavior, to see if there's a solution that wasn't considered back then.

simoneb avatar Sep 05 '24 14:09 simoneb

@aboutlo are you able to chime in on this?

esatterwhite avatar Jul 06 '25 12:07 esatterwhite