Vogen icon indicating copy to clipboard operation
Vogen copied to clipboard

swashbuckle extension for schema mappings in a separate project

Open StealthyDeveloper opened this issue 7 months ago • 1 comments

Describe the feature

Currently in order for the swashbuckle extension method to be generated the [assembly: VogenDefaults( openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod)] has to be put somewhere inside the project of the value objects. This means a hard dependency on Swashbuckle.AspNetCore.SwaggerGen and thus also on asp.net.core is required for the domain project.

I'd like to be able to generate the extension in my api project for all referenced value objects.

The workaround now is to write out the mappings manually in the api project and not use the extension method.

StealthyDeveloper avatar May 07 '25 20:05 StealthyDeveloper

Thanks for the feedback @StealthyDeveloper - I've added partial support for this for Open API 2.0+

In your web api project, add something like this:

[OpenApiMarker<City>]
[OpenApiMarker<Age>]
[OpenApiMarker<Name>]
public partial class OpenApiMarkers;

Then, you can use:

    builder.Services.AddOpenApi((OpenApiOptions o) =>
    {
        o.MapVogenTypesInOpenApiMarkers();
    });

I'll add this feature to the next beta release if you'd like to try it?

SteveDunn avatar Nov 26 '25 22:11 SteveDunn