-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Custom JSON serializer #609
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
Comments
Currently not possible, but we should refactor to use JsonContract for generation: RicoSuter/NJsonSchema#321 |
What exactly did you customize in the contract resolver? |
We have swedish characters in our internal models that we need to escape for the Typescript generator to work. The contract resolver takes care of that. |
Ideally we might not have Swedish characters in our models. However if the WebAPI is set up to use a custom contract resolver this should be respected by Swagger. |
Where do you have Swedish characters? In the property names? |
Yep, property and type names. |
Can you give some samples, i think this is just a fix in the property name generator |
Sure thing!
Then we have our custom contract resolver that escapes the Swedish characters like this
For the type names we have another issue as that's not part of the contract resolver. |
v11 of NSwag has the new ContractResolver-based implementation... You can now provide your resolver so that your serialization logic is used... |
Please test with the CI artifacts and report and problems... |
We have implemented a custom contract resolver for our WebAPI defined in
Application_Start
like this:config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CustomContractResolver();
It works great for the WebAPI but it's not respected by Swagger. Looking at the
SwaggerUiOwinSettings
we use to inject Swagger into the project, we can only set a fixed set of contract resolvers defined inNJsonSchema.PropertyNameHandling
using the config parameterDefaultPropertyNameHandling
.Is it possible to configure Swagger to use our custom contract resolver or any other way around this?
The text was updated successfully, but these errors were encountered: