public class WorkflowRequestDto{ [XmlElement(Constants.CreateByWorkflowTagName)] //this is public const string CreateByWorkflowTagName = "create-by-workflow"; public WorkflowNameDto WorkflowName { get; set; }}public class WorkflowNameDto{ [XmlElement(Constants.WorkflowNameTagName)] // this is public const string WorkflowNameTagName = "workflow-name"; public string WorkflowName { get; set; }}
OK. I must be missing some vital piece of information here. You asked how to serialize a C# class into an XML, which I've shown you how to do, but you keep referring to JSON without explaining how that fits in with your question.
Currently you have 2 classes, and I've shown you how to serialize those to the XML that you requested using the attributes. Can you explain how Swagger and JSON fits into that. Are you wanting to serialize the classes into JSON ? Are you wanting to serialize the XML into JSON ?