fsprojects / FSharp.Data.JsonSchema

MIT License
48 stars 6 forks source link

Question: How does one generate the JsonSchema "required" field #9

Open dergraf opened 3 years ago

dergraf commented 3 years ago

Hello

F# beginner here.. I was playing with generating a Json Schema from a simple record type. To my understand all record properties are required, but this isn't reflected in the generated JsonSchema using the "required" field (https://json-schema.org/understanding-json-schema/reference/object.html#required-properties) What I have seen the underlying Njsonschema should support this using DataAnnotations, but I am not sure if this is the way to go here. Anyways, I guess I am missing something, I would appreciate if you can point me towards the right direction. Thanks!

panesofglass commented 3 years ago

I'm not sure. If you can test using data annotations and let me know, I'd appreciate it. I haven't needed that yet, so I hadn't made any tests for it. We should probably add tests for these kinds of things and then address them.

panesofglass commented 3 years ago

I'm thinking of using the Option<'T> type as a means of determining what's required. What do you think? NJsonSchema attributes should also work as that is the underlying engine for generating the JSON Schema.

panesofglass commented 3 years ago

@dergraf I haven't quite figured out how to force the required attribute, but do you find #12 to improve some of what you were seeing before?