'Swagger doesn't work with specific named models
Im having trouble with getting swagger to work with my models. I have an endpoint which takes in an object which has a property that takes an RequestActionType enum.
I get the Failed to load API definition Internal Server Error .../swagger.json error. BUT if I change the name of the pr RequestActionType it works fine.
What could be causing this?
Solution 1:[1]
So the issue was that I had the same enum in two places, but with different namespaces. After doing a bit more research, I found that by default swagger uses just the class name as a schemaId. So the above will throw an error due to duplicate class. To get swagger to use the full namespace we need to set the below code in the startup.cs when configuring swagger.
c.CustomSchemaIds(x => x.FullName);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fahad Jameel |
