tamasfe/aide

Referenced objects are always inlined

tomas789 opened this issue · 1 comments

I've run into an issue where referenced objects were always inlined instead of using references (#/components/schemas/ChartItem). The problem went away when I removed the s.definitions_path setting to #/components/schemas/ but that leads to JSON schema-style references instead of OpenAPI-style ones.

I managed to fix the issue by setting it to the openapi3 settings. Here is my workaround

aide::gen::in_context(|ctx: &mut aide::gen::GenContext| {
    ctx.schema = SchemaGenerator::new(SchemaSettings::openapi3());
});

Is there a reason for not using openapi3 settings? My first guess was that this was added only after creating Aide but it looks like this is not the case.

you can do this at the beginning of the program:

aide::gen::extract_schemas(false);

This was changed to the default to reduce the size of generated openapi files, as without extraction they are duplicated and can create issues with recursive structures.