Changing schemars' generation settings
While using aide I'd like to change schemars' settings, specifically I'd like to disable making Options being turned into anyOfs with nulls. Schemars supports this by setting option_nullable = true and option_add_null_type = false on its settings struct which I can do by doing something like this:
aide::gen::in_context(|ctx| {
ctx.schema = schemars::gen::SchemaGenerator::new(schemars::gen::SchemaSettings::draft07().with(|s| {
s.option_nullable = true;
s.option_add_null_type = false;
}));
});
But if I want to use other aide features such as schema extraction then this isn't going to work because that also modifies the schema generator. I worked around this for now by just looking at the source and making the same modifications on the schema settings as extract_schemas does, but this is not optimal as it requires me to know internals of aide. Would you consider exposing these settings through aide so this is not required?
After some brief thinking I believe your approach is the way to go here. By default aide aims to conform to the OpenAPI spec during schema generation with sensible defaults. If you need to alter this in any way and you know what you're looking for, the schema generator is exposed and it's possible to do so.
I would rather not expose individual features of schemars one by one. The extract_schemas setting is an exception; I exposed it as a high-level switch because it's a behaviour people generally expect from doc generators but is disabled by default because schemars doesn't handle name conflicts.