C# Generation that shares existing DTO project #5867
Replies: 4 comments 4 replies
-
Yes, this is possible. With Kiota, you can customize the generation process to use your existing DTOs instead of generating new ones. Here are the key steps: Configure Kiota to skip DTO generation In your Kiota generation command or configuration, you'll want to use options that prevent regenerating DTOs and instead use your existing types. The exact method depends on your specific Kiota setup, but typically involves specifying a custom namespace mapping or using configuration flags to reference existing types. |
Beta Was this translation helpful? Give feedback.
-
sure bro, I'll help you configure Kiota to use your existing DTOs. Here's a detailed approach:
In your Kiota generation command, you'll want to add flags like: kiota generate \
--openapi path/to/openapi.json \
--output ./generated \
--namespace-mapping "Your.Existing.Namespace=YourSharedProject.Models" \
--skip-generation-if-type-exists \
--exclude-type-names "ListOfYourDTOsToSkip" Key configuration points: Use --namespace-mapping to tell Kiota about your existing types In your project: Reference your shared DTOs project |
Beta Was this translation helpful? Give feedback.
-
but ListOfYourExistingDTOs may be a full list of every single class? thanks |
Beta Was this translation helpful? Give feedback.
-
This would be extremely useful in my case also if this were possible. We have many complex polymorphic models that are being duplicated in our kiota client and having to be mapped to other models because of this duplication. We have APIs where we will retrieve a given model and use that same model to pass to another API. Currently we are using tools like AutoMapper to do this but it's a bit of a pain and has caveats. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have a C# minimal api server that generates an openapi.json file. All of our DTOs are in a separate shared project. I'd like to reuse that shared project instead of having Kiota generate a less accurate version of those DTOs so that our Maui/Uno project can just reference the shared library along with the shared client.
Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions