I have a WebAPI endpoint that implements two different versions of the API (legacy and new). Inherited endpoints use a specific Serializer that has all objects serialized as lowercase words with underscores, endpoint v2 uses camel shell property names. For example, V1 = "document_type" and V2 = "documentType"
Currently, this is achieved using special controller attributes to determine serialization, for example:
public class CamelCaseControllerConfiguration : Attribute, IControllerConfiguration { public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) { controllerSettings.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); controllerSettings.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter()); } }
All this works fine when invoking a client via REST, but the documentation created by Swagger always shows property names using outdated serializer options. Any suggestions on tweaking swashbuckle to properly serialize each version?
Kris
source share