Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/SwaggerWcf/Models/DefinitionSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ internal class DefinitionSchema

public List<int> Enum { get; set; }

public string XmlFormatNamespace { get; set; }

public void Serialize(JsonWriter writer)
{
if (TypeFormat.Type == ParameterType.Object)
Expand Down Expand Up @@ -54,6 +56,8 @@ public void Serialize(JsonWriter writer)

SerializeProperties(writer);

SerializeXmlNamespace(writer);

if (ParentSchema != null)
{
writer.WriteEndObject();
Expand Down Expand Up @@ -136,5 +140,17 @@ private void SerializeProperties(JsonWriter writer)
writer.WriteEndObject();
}
}

private void SerializeXmlNamespace(JsonWriter writer)
{
if (!string.IsNullOrWhiteSpace(XmlFormatNamespace))
{
writer.WritePropertyName("xml");
writer.WriteStartObject();
writer.WritePropertyName("namespace");
writer.WriteValue(XmlFormatNamespace);
writer.WriteEndObject();
}
}
}
}
5 changes: 5 additions & 0 deletions src/SwaggerWcf/Support/DefinitionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ private static void ProcessTypeAttributes(Type definitionType, DefinitionSchema
if (descAttr != null)
schema.Description = descAttr.Description;

DataContractAttribute dataContractAttr =
definitionType.GetCustomAttribute<DataContractAttribute>();
if (dataContractAttr != null && !string.IsNullOrWhiteSpace(dataContractAttr.Namespace))
schema.XmlFormatNamespace = dataContractAttr.Namespace;

SwaggerWcfDefinitionAttribute definitionAttr =
definitionType.GetCustomAttribute<SwaggerWcfDefinitionAttribute>();
if (definitionAttr != null)
Expand Down