Browse Source

fix: title to name; fix: swagger HTTPS support on docgen

码农 6 years ago
parent
commit
83ff983b25

+ 1 - 1
MyTrelloWeb/App/ApiModule.cs

@@ -14,7 +14,7 @@ namespace MyTrelloWeb.App
         public ApiModule() : base("MyTrello", "dev", "/api", new Dictionary<string, Type>
         {
             {"Kanban", typeof(IKanbanService)},
-        })
+        }, "http", "https")
         {
         }
 

+ 10 - 10
MyTrelloWeb/App/AppServices/KanbanService.cs

@@ -17,7 +17,7 @@ namespace MyTrelloWeb.App.AppServices
 
         ListSummaryOutput ListSummary(QueryByIdInput input);
 
-        KanbanEntryCreateOutput ListCreate(CreateWithTitleInput input); //TODO: Kanban ID
+        KanbanEntryCreateOutput ListCreate(CreateWithNameInput input); //TODO: Kanban ID
 
         void ListRename(ContentInput input);
 
@@ -29,7 +29,7 @@ namespace MyTrelloWeb.App.AppServices
 
         CardDetailOutput CardDetail(QueryByIdInput input);
 
-        KanbanEntryCreateOutput CardCreate(CreateWithTitleAndParentIdInput input);
+        KanbanEntryCreateOutput CardCreate(CreateWithNameAndParentIdInput input);
 
         void CardRename(ContentInput input);
 
@@ -41,7 +41,7 @@ namespace MyTrelloWeb.App.AppServices
 
         // manifest level
 
-        KanbanEntryCreateOutput ManifestCreate(CreateWithTitleAndParentIdInput input);
+        KanbanEntryCreateOutput ManifestCreate(CreateWithNameAndParentIdInput input);
 
         void ManifestMove(MoveInput input);
 
@@ -51,7 +51,7 @@ namespace MyTrelloWeb.App.AppServices
 
         // item level
 
-        KanbanEntryCreateOutput ItemCreate(CreateWithTitleAndParentIdInput input);
+        KanbanEntryCreateOutput ItemCreate(CreateWithNameAndParentIdInput input);
 
         void ItemMove(MoveInput input);
 
@@ -136,13 +136,13 @@ namespace MyTrelloWeb.App.AppServices
             };
         }
 
-        KanbanEntryCreateOutput IKanbanService.ListCreate(CreateWithTitleInput input)
+        KanbanEntryCreateOutput IKanbanService.ListCreate(CreateWithNameInput input)
         {
             var ne = new KanbanEntity
             {
                 //TODO: Kanban ID
                 Type = KanbanEntryType.List,
-                Name = input.Title,
+                Name = input.Name,
             };
 
             using (var repo = GetRepository())
@@ -198,7 +198,7 @@ namespace MyTrelloWeb.App.AppServices
             throw new NotImplementedException();
         }
 
-        KanbanEntryCreateOutput IKanbanService.CardCreate(CreateWithTitleAndParentIdInput input)
+        KanbanEntryCreateOutput IKanbanService.CardCreate(CreateWithNameAndParentIdInput input)
         {
             KanbanEntity ne;
 
@@ -214,7 +214,7 @@ namespace MyTrelloWeb.App.AppServices
                 {
                     Type = KanbanEntryType.Card,
                     ListId = input.ParentId,
-                    Name = input.Title,
+                    Name = input.Name,
                 };
 
                 var existedCount = repo.Query(p => p.Type == KanbanEntryType.Card && p.ListId == input.ParentId).Count();
@@ -266,7 +266,7 @@ namespace MyTrelloWeb.App.AppServices
             throw new NotImplementedException();
         }
 
-        KanbanEntryCreateOutput IKanbanService.ManifestCreate(CreateWithTitleAndParentIdInput input)
+        KanbanEntryCreateOutput IKanbanService.ManifestCreate(CreateWithNameAndParentIdInput input)
         {
             throw new NotImplementedException();
         }
@@ -286,7 +286,7 @@ namespace MyTrelloWeb.App.AppServices
             throw new NotImplementedException();
         }
 
-        KanbanEntryCreateOutput IKanbanService.ItemCreate(CreateWithTitleAndParentIdInput input)
+        KanbanEntryCreateOutput IKanbanService.ItemCreate(CreateWithNameAndParentIdInput input)
         {
             throw new NotImplementedException();
         }

+ 1 - 1
MyTrelloWeb/App/Dto/CreateWithTitleAndParentIdInput.cs

@@ -3,7 +3,7 @@ using MyTrelloWeb.VCommon.DataAnnotations.ExtraValidation;
 
 namespace MyTrelloWeb.App.Dto
 {
-    public class CreateWithTitleAndParentIdInput : CreateWithTitleInput
+    public class CreateWithNameAndParentIdInput : CreateWithNameInput
     {
         [NoEmptyGuid]
         public Guid ParentId { get; set; }

+ 2 - 2
MyTrelloWeb/App/Dto/CreateWithTitleInput.cs

@@ -2,10 +2,10 @@
 
 namespace MyTrelloWeb.App.Dto
 {
-    public class CreateWithTitleInput
+    public class CreateWithNameInput
     {
         [Required]
-        public string Title { get; set; }
+        public string Name { get; set; }
 
     }
 }

+ 2 - 2
MyTrelloWeb/MyTrelloWeb.csproj

@@ -235,8 +235,8 @@
     <Compile Include="App\Dto\CardDetailOutput.cs" />
     <Compile Include="App\Dto\CardSummaryOutput.cs" />
     <Compile Include="App\Dto\CheckInput.cs" />
-    <Compile Include="App\Dto\CreateWithTitleAndParentIdInput.cs" />
-    <Compile Include="App\Dto\CreateWithTitleInput.cs" />
+    <Compile Include="App\Dto\CreateWithNameAndParentIdInput.cs" />
+    <Compile Include="App\Dto\CreateWithNameInput.cs" />
     <Compile Include="App\Dto\DeleteByIdInput.cs" />
     <Compile Include="App\Dto\KanbanEntryCreateOutput.cs" />
     <Compile Include="App\Dto\KanbanSummaryBase.cs" />

+ 4 - 2
MyTrelloWeb/VCommon/VOpenApi/Docgen/DocGenerator.cs

@@ -11,7 +11,7 @@ namespace MyTrelloWeb.VCommon.VOpenApi.Docgen
 {
     public static class DocGenerator
     {
-        public static string Generate(string name, string version, string basePath, IEnumerable<ApiBind> binds)
+        public static string Generate(string name, string version, string basePath, IEnumerable<ApiBind> binds, IReadOnlyCollection<string> schemes)
         {
             var doc = new SwaggerDocument
             {
@@ -21,7 +21,9 @@ namespace MyTrelloWeb.VCommon.VOpenApi.Docgen
                     version = version,
                 },
                 basePath = basePath,
-                schemes = new[] { "http" },
+                schemes = schemes.Count == 0
+                    ? new[] { "http" }
+                    : schemes.ToArray(),
                 host = "",
                 paths = new Dictionary<string, PathItem>(),
             };

+ 10 - 7
MyTrelloWeb/VCommon/VOpenApi/OpenApiModuleBase.cs

@@ -1,12 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Web;
-using MyTrelloWeb.VCommon.Json;
+using MyTrelloWeb.VCommon.Json;
 using MyTrelloWeb.VCommon.Logging;
 using MyTrelloWeb.VCommon.Reflection;
 using MyTrelloWeb.VCommon.VApplication;
 using MyTrelloWeb.VCommon.VOpenApi.Docgen;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Web;
 
 namespace MyTrelloWeb.VCommon.VOpenApi
 {
@@ -22,10 +22,13 @@ namespace MyTrelloWeb.VCommon.VOpenApi
 
         private IReadOnlyDictionary<string, ApiBind> _apiRoutes;
         private string _openApiDoc;
+        private IReadOnlyCollection<string> _schemes;
 
         /// <param name="baseApiPath">不带斜杠结尾</param>
-        protected ApiModuleBase(string title, string version, string baseApiPath, IReadOnlyDictionary<string, Type> services)
+        protected ApiModuleBase(string title, string version, string baseApiPath, IReadOnlyDictionary<string, Type> services, params string[] schemes)
         {
+            _schemes = schemes;
+
             Title = title;
             Version = version;
             BaseApiPath = baseApiPath;
@@ -80,7 +83,7 @@ namespace MyTrelloWeb.VCommon.VOpenApi
                 _apiRoutes = apiRoutes;
 
                 _openApiDoc = EnableDocGen
-                   ? DocGenerator.Generate(Title, Version, BaseApiPath, _apiRoutes.Values)
+                   ? DocGenerator.Generate(Title, Version, BaseApiPath, _apiRoutes.Values, _schemes)
                    : VJsonSerializer.Serialize(new { docGen = false });
 
                 //一切顺利才加挂请求处理事件,否则就当模块不存在