From 1eebd6a978d8a02cf861cffe189d4c7b4954350a Mon Sep 17 00:00:00 2001 From: Rico Suter Date: Wed, 14 Mar 2018 23:42:41 +0100 Subject: [PATCH] Improved SwaggerOperations --- src/NSwag.Core/SwaggerDocument.Serialization.cs | 8 ++++++++ src/NSwag.Core/SwaggerOperationMethod.cs | 6 +++++- src/NSwag.Core/SwaggerOperations.cs | 15 ++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/NSwag.Core/SwaggerDocument.Serialization.cs b/src/NSwag.Core/SwaggerDocument.Serialization.cs index 68ad061442..bac9a07285 100644 --- a/src/NSwag.Core/SwaggerDocument.Serialization.cs +++ b/src/NSwag.Core/SwaggerDocument.Serialization.cs @@ -37,6 +37,9 @@ public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerial //resolver.IgnoreProperty(typeof(SwaggerDocument), "consumes"); //resolver.IgnoreProperty(typeof(SwaggerDocument), "produces"); + //resolver.IgnoreProperty(typeof(SwaggerResponse), "consumes"); => TODO map to response.content + //resolver.IgnoreProperty(typeof(SwaggerResponse), "produces"); + resolver.IgnoreProperty(typeof(SwaggerDocument), "definitions"); resolver.IgnoreProperty(typeof(SwaggerDocument), "parameters"); resolver.IgnoreProperty(typeof(SwaggerDocument), "responses"); @@ -50,6 +53,11 @@ public static PropertyRenameAndIgnoreSerializerContractResolver CreateJsonSerial resolver.IgnoreProperty(typeof(SwaggerDocument), "servers"); resolver.IgnoreProperty(typeof(SwaggerParameter), "title"); + // TODO: Use rename for not mapped properties! + resolver.IgnoreProperty(typeof(SwaggerOperations), "summary"); + resolver.IgnoreProperty(typeof(SwaggerOperations), "description"); + resolver.IgnoreProperty(typeof(SwaggerOperations), "servers"); + resolver.IgnoreProperty(typeof(SwaggerDocument), "components"); resolver.IgnoreProperty(typeof(SwaggerParameter), "examples"); } diff --git a/src/NSwag.Core/SwaggerOperationMethod.cs b/src/NSwag.Core/SwaggerOperationMethod.cs index 55f1c9e53b..c446d284c9 100644 --- a/src/NSwag.Core/SwaggerOperationMethod.cs +++ b/src/NSwag.Core/SwaggerOperationMethod.cs @@ -46,6 +46,10 @@ public enum SwaggerOperationMethod /// The HTTP PATCH method. [EnumMember(Value = "patch")] - Patch + Patch, + + /// The HTTP TRACE method (OpenAPI only). + [EnumMember(Value = "trace")] + Trace } } \ No newline at end of file diff --git a/src/NSwag.Core/SwaggerOperations.cs b/src/NSwag.Core/SwaggerOperations.cs index 1fb06d8453..f99cd42189 100644 --- a/src/NSwag.Core/SwaggerOperations.cs +++ b/src/NSwag.Core/SwaggerOperations.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using Newtonsoft.Json; using NSwag.Collections; @@ -32,9 +33,21 @@ public SwaggerOperations() [JsonIgnore] public SwaggerDocument Parent { get; internal set; } + /// Gets or sets the summary (OpenApi only). + [JsonProperty(PropertyName = "summary", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public string Summary { get; set; } + + /// Gets or sets the description (OpenApi only). + [JsonProperty(PropertyName = "description", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public string Description { get; set; } + + /// Gets or sets the servers (OpenAPI only). + [JsonProperty(PropertyName = "servers", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public ICollection Servers { get; set; } = new Collection(); + /// Gets or sets the parameters. [JsonProperty(PropertyName = "parameters", DefaultValueHandling = DefaultValueHandling.Ignore)] - public List Parameters { get; set; } + public ICollection Parameters { get; set; } = new Collection(); // Needed to convert dictionary keys to lower case internal class SwaggerOperationsJsonConverter : JsonConverter