-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swaggergen not using custom json converter #2500
Comments
Ran into same problem, different use case. I found two spots I had to band-aid. First is that primitive types are not configurable. I was adding DateOnly, which would be considered a primitive. Following custom JsonSerializerDataContractResolver fixed that for me: `
` Second snag was that JsonOptions didn't get picked up. There is a condition for NetStandard2.0 in the code, which I think needs to be updated so it also includes .NET 6 and NetStandard2.1. Following registration, combined with the custom class above, fixed that:
|
|
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made. |
#2799 should fix support for If there's something needing tweaking to get the custom converter used correctly we can fix that too. |
I see that both I haven't yet found the code path with the missing use of the serializer options though. |
Right, I understand now. We should look at adding the capability to do that if possible, as well as for both types of resolver to allow the user to add custom mappings. That would allow users to self-configure additional types that we don't support yet in the future, e.g. if there was ever a |
We are using mongodb which has an ObjectId type (struct). We use a JsonConverter to serialize this as a string, This converter is registered using builder.Services.AddJsonOptions. It works perfectly in our actual API.
However when the swagger is generated the examples have it serialised as an object:
Things we have tried which didn't work:
The text was updated successfully, but these errors were encountered: