Skip to content
Discussion options

You must be logged in to vote

This feature is was merged some time ago. You can use glz::opts{.error_on_missing_keys = true} when calling write_json_schema to mark all non-nullable fields as required in the generated schema.

Example

#include <glaze/glaze.hpp>

struct Address
{
   std::string street{};
   std::string city{};
   std::optional<std::string> apartment{}; // nullable - will NOT be required
};

struct Person
{
   std::string name{};
   int age{};
   std::optional<std::string> nickname{}; // nullable - will NOT be required
   Address address{};
};

int main()
{
   // Generate schema with all non-nullable fields marked as required
   auto schema = glz::write_json_schema<Person, glz::opts{.error_on_missing_keys = 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stephenberry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants