From 64f28b8aef634427a9fbcddfffe8cd1d90f3272c Mon Sep 17 00:00:00 2001 From: Alexander Kykc Date: Wed, 30 Nov 2016 22:08:13 +0200 Subject: [PATCH 1/2] produces and consumes sections implemented --- .../Fluent/SwaggerEndpointInfoExtensions.cs | 14 ++++++++++++++ .../Model/SwaggerEndpointInfo.cs | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs b/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs index 945136b..f3dbc22 100644 --- a/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs +++ b/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs @@ -10,6 +10,20 @@ namespace Nancy.Metadata.Swagger.Fluent { public static class SwaggerEndpointInfoExtensions { + public static SwaggerEndpointInfo WithProduces(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) + { + endpointInfo.Produces = contentTypes.Length > 0 ? contentTypes : null; + + return endpointInfo; + } + + public static SwaggerEndpointInfo WithConsumes(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) + { + endpointInfo.Consumes = contentTypes.Length > 0 ? contentTypes : null; + + return endpointInfo; + } + public static SwaggerEndpointInfo WithResponseModel(this SwaggerEndpointInfo endpointInfo, string statusCode, Type modelType, string description = null) { if (endpointInfo.ResponseInfos == null) diff --git a/Nancy.Metadata.Swagger/Model/SwaggerEndpointInfo.cs b/Nancy.Metadata.Swagger/Model/SwaggerEndpointInfo.cs index 2f611e2..d766d5a 100644 --- a/Nancy.Metadata.Swagger/Model/SwaggerEndpointInfo.cs +++ b/Nancy.Metadata.Swagger/Model/SwaggerEndpointInfo.cs @@ -19,5 +19,9 @@ public class SwaggerEndpointInfo [JsonProperty("parameters")] public List RequestParameters { get; set; } + [JsonProperty("consumes")] + public string[] Consumes { get; set; } + [JsonProperty("produces")] + public string[] Produces { get; set; } } } \ No newline at end of file From 63085af56cc255d180dad70708ba47280fcdcff8 Mon Sep 17 00:00:00 2001 From: Alexander Kykc Date: Sat, 10 Dec 2016 21:56:23 +0200 Subject: [PATCH 2/2] fixed newlines --- .../Fluent/SwaggerEndpointInfoExtensions.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs b/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs index f3dbc22..e51e18b 100644 --- a/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs +++ b/Nancy.Metadata.Swagger/Fluent/SwaggerEndpointInfoExtensions.cs @@ -10,18 +10,18 @@ namespace Nancy.Metadata.Swagger.Fluent { public static class SwaggerEndpointInfoExtensions { - public static SwaggerEndpointInfo WithProduces(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) - { - endpointInfo.Produces = contentTypes.Length > 0 ? contentTypes : null; - - return endpointInfo; + public static SwaggerEndpointInfo WithProduces(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) + { + endpointInfo.Produces = contentTypes.Length > 0 ? contentTypes : null; + + return endpointInfo; } - public static SwaggerEndpointInfo WithConsumes(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) - { - endpointInfo.Consumes = contentTypes.Length > 0 ? contentTypes : null; - - return endpointInfo; + public static SwaggerEndpointInfo WithConsumes(this SwaggerEndpointInfo endpointInfo, params string[] contentTypes) + { + endpointInfo.Consumes = contentTypes.Length > 0 ? contentTypes : null; + + return endpointInfo; } public static SwaggerEndpointInfo WithResponseModel(this SwaggerEndpointInfo endpointInfo, string statusCode, Type modelType, string description = null)