public void Serialize(JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("swagger"); writer.WriteValue(Swagger); if (Info != null) { writer.WritePropertyName("info"); Info.Serialize(writer); } if (Host != null) { writer.WritePropertyName("host"); writer.WriteValue(Host); } if (BasePath != null) { writer.WritePropertyName("basePath"); writer.WriteValue(BasePath); } if (Schemes != null && Schemes.Any()) { writer.WritePropertyName("schemes"); writer.WriteStartArray(); foreach (string sch in Schemes) { writer.WriteValue(sch); } writer.WriteEndArray(); } if (Paths != null && Paths.Any()) { writer.WritePropertyName("paths"); WritePaths(writer); } if (Definitions != null && Definitions.Any()) { writer.WritePropertyName("definitions"); WriteDefinitions(writer); } if (SecurityDefinitions != null && SecurityDefinitions.Any()) { writer.WritePropertyName("securityDefinitions"); WriteSecurityDefinitions(writer); } if (Tags?.Count > 0) { writer.WritePropertyName("tags"); var tagsValue = JsonConvert.SerializeObject(Tags); writer.WriteRawValue(tagsValue); } writer.WriteEndObject(); }
public void Serialize(JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("swagger"); writer.WriteValue(Swagger); if (Info != null) { writer.WritePropertyName("info"); Info.Serialize(writer); } if (Host != null) { writer.WritePropertyName("host"); writer.WriteValue(Host); } if (BasePath != null) { writer.WritePropertyName("basePath"); writer.WriteValue(BasePath); } if (Schemes != null && Schemes.Any()) { writer.WritePropertyName("schemes"); WriteSchemes(writer); } if (Paths != null && Paths.Any()) { writer.WritePropertyName("paths"); WritePaths(writer); } if (Definitions != null && Definitions.Any()) { writer.WritePropertyName("definitions"); WriteDefinitions(writer); } writer.WriteEndObject(); }
//public List<Security> security { get; set; } public void Serialize(JsonWriter writer) { writer.WritePropertyName(Id); writer.WriteStartObject(); if (Tags != null && Tags.Any()) { writer.WritePropertyName("tags"); writer.WriteStartArray(); foreach (string tag in Tags) { writer.WriteValue(tag); } writer.WriteEndArray(); } if (!string.IsNullOrWhiteSpace(Summary)) { writer.WritePropertyName("summary"); writer.WriteValue(Summary); } if (!string.IsNullOrWhiteSpace(Description)) { writer.WritePropertyName("description"); writer.WriteValue(Description); } if (ExternalDocs != null) { writer.WritePropertyName("externalDocs"); ExternalDocs.Serialize(writer); } if (!string.IsNullOrWhiteSpace(OperationId)) { writer.WritePropertyName("operationId"); writer.WriteValue(OperationId); } if (Consumes != null && Consumes.Any()) { writer.WritePropertyName("consumes"); writer.WriteStartArray(); foreach (string cons in Consumes) { writer.WriteValue(cons); } writer.WriteEndArray(); } if (Produces != null && Produces.Any()) { writer.WritePropertyName("produces"); writer.WriteStartArray(); foreach (string prod in Produces) { writer.WriteValue(prod); } writer.WriteEndArray(); } if (Parameters != null && Parameters.Any()) { writer.WritePropertyName("parameters"); writer.WriteStartArray(); foreach (ParameterBase p in Parameters) { p.Serialize(writer); } writer.WriteEndArray(); } if (Responses != null && Responses.Any()) { writer.WritePropertyName("responses"); writer.WriteStartObject(); foreach (Response r in Responses) { r.Serialize(writer); } writer.WriteEndObject(); } if (Schemes != null && Schemes.Any()) { writer.WritePropertyName("schemes"); writer.WriteStartArray(); foreach (string sch in Schemes) { writer.WriteValue(sch); } writer.WriteEndArray(); } if (Deprecated) { writer.WritePropertyName("deprecated"); writer.WriteValue(Deprecated); } writer.WriteEndObject(); }
public bool CanHandleUrl(string url) { return(Schemes.Any(p => Regex.IsMatch(url, p))); }