I have several public classes (models) in my API that are not being exposed through the controllers. Is there a way to get them manually or a keyword to expose them so that when I download the contract they show up? Without having to create dummy controllers that pretend to use them.
Asked
Active
Viewed 899 times
1
-
Does this answer your question? [Using Swashbuckle for Asp.net core how can I add a model to the generated model list?](https://stackoverflow.com/questions/49006079/using-swashbuckle-for-asp-net-core-how-can-i-add-a-model-to-the-generated-model) – sellotape Aug 31 '21 at 08:05
-
I have a strait question: Why exactly would you exclude these classes from being in the controllers? What case do you have exactly to EXCLUDE them from controllers indefinitely? I have never seen this case before and would like to learn more about why you are doing this, and what your case is specifically that excludes the possibility of including them in controllers. Thanks. – Judy007 Sep 10 '22 at 12:49
-
@jb007: I had a similar issue, but it was not about something was excluded. The issue was, there was no controller accepting or returning the type, so it was not included in the swagger.json. Nevertheless we liked to add the type into manually into swagger, cause another project generated its structure out of the swagger.json and it was the easiest way to keep both sides _automatically_ in sync. I think this is here similar. The linked answer should help to manually add models to your swagger. – Oliver Sep 10 '22 at 13:05
-
@Oliver, if there is no controller accepting the or returning the type, then logically there is no need to include it in the swagger. – Judy007 Sep 11 '22 at 22:21