zeeshanlakhani / schema-gen

Turn Prismatic schemas into generated data.
Eclipse Public License 1.0
34 stars 3 forks source link

the s/Num clause has interesting inheritance properties #15

Open gfredericks opened 9 years ago

gfredericks commented 9 years ago

(schema->gen BigDecimal) returns a generator of floats, when I'd prefer that it would crash because it doesn't know how to generate BigDecimal.

The reason it does this is because the s/Num clause is using the java.lang.Number class which is a superclass of BigDecimal.

I think inheritance for generators kind of works in the opposite direction (IS THIS WHAT CONTRAVARIANT MEANS??).

Not sure what the best fix is. Only idea I have is swapping s/Num for Double.

gfredericks commented 9 years ago

also worth pointing out that once I add my own (defmethod schema->gen BigDecimal ...) everything is fine -- the problem is just that I was confused prior to adding it.