Closed mkalinski93 closed 3 weeks ago
Thank you for the bug report @mkalinski93 . Apologies for that. I'll take a look shortly!
Unfortunately, source generators are per-project, so it can't inspect any types found in other projects. A workaround would be to generate the same extension method in your library. But unfortunately, it writes this method without a namespace. So, without an import alias when you reference the project, you won't be able to differentiate.
To make this easier, I've made it generate the default namespace of the project. If you have types that need mapping and they're in different projects, then you'll need to change the registration:
//opt.MapVogenTypes(); old way -for unambiguous extension method
// when you have multiple projects with types that need mapping:
WebApplication.VogenSwashbuckleExtensions.MapVogenTypes(opt);
WebApplication.Shared.VogenSwashbuckleExtensions.MapVogenTypes(opt);
I've update the examples to show this too. In your library with value objects, add package Swashbuckle.AspNetCore
and an assembly attribute:
[assembly: VogenDefaults(
openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleSchemaFilter | OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod,
staticAbstractsGeneration: StaticAbstractsGeneration.MostCommon | StaticAbstractsGeneration.InstanceMethodsAndProperties]
This is currently in a branch and I'll release as part of the next beta soon.
Thanks again for the report
In 5.0.5-beta3
Describe the bug
I have a multi repo project that I´m working on and I was using the MapVogenTypes extension method for SwaggerGen. It seems to me, that it can only find ValueObjects in the same Assembly.
Steps to reproduce
This case works. Here comes the issue
MapVogenTypes will not resolve the ValueObject that remains in the Class library.
Expected behaviour
Types should have been mapped