fsprojects / FSharp.Data.JsonSchema

MIT License
49 stars 6 forks source link

Question: How to add schema generator for recursive type? #15

Open blakeSaucier opened 1 year ago

blakeSaucier commented 1 year ago

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

panesofglass commented 1 year ago

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

Tarmil commented 1 year ago

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.