FSharp.Data.JsonSchema icon indicating copy to clipboard operation
FSharp.Data.JsonSchema copied to clipboard

Question: How to add schema generator for recursive type?

Open blakeSaucier opened this issue 3 years ago • 2 comments

Hello,

I have a recursive DU as part of my model:

type Node =
  | Leaf of int
  | Node of Node * Node 

Currently the Schema Generator gets caught in an endless loop when asked to generate a Json Schema.

I would offer a PR however I'm not sure how to add this feature.

Thanks

blakeSaucier avatar Nov 23 '22 18:11 blakeSaucier

That's an excellent question. I haven't attempted this. @Tarmil, do you have any suggestions?

panesofglass avatar Jan 03 '23 21:01 panesofglass

Looks like the way to handle recursive types in JSON schemas is using $ref. I'm not familiar with how to do this with NJsonSchema though.

Tarmil avatar Jan 04 '23 09:01 Tarmil