From eddd9b6a168a3386f2c7c741da562e5d4ee21ad6 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 13 Jul 2021 17:27:05 +0800 Subject: [PATCH 1/3] remove reduce logic in adding IColletion --- .../languages/CSharpNetCoreClientCodegen.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java index 2e0a3bd12233..96c7c92f5eca 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java @@ -468,33 +468,6 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert super.postProcessModelProperty(model, property); } - @Override - public Map postProcessOperationsWithModels(Map objs, List allModels) { - super.postProcessOperationsWithModels(objs, allModels); - if (objs != null) { - Map operations = (Map) objs.get("operations"); - if (operations != null) { - List ops = (List) operations.get("operation"); - for (CodegenOperation operation : ops) { - if (operation.returnType != null) { - operation.returnContainer = operation.returnType; - if (this.returnICollection && ( - operation.returnType.startsWith("List") || - operation.returnType.startsWith("Collection"))) { - // NOTE: ICollection works for both List and Collection - int genericStart = operation.returnType.indexOf("<"); - if (genericStart > 0) { - operation.returnType = "ICollection" + operation.returnType.substring(genericStart); - } - } - } - } - } - } - - return objs; - } - @Override public void postProcessParameter(CodegenParameter parameter) { postProcessPattern(parameter.pattern, parameter.vendorExtensions); From 7345f4a7eb670caa50f3aa64d29a26e2681c1fa5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 13 Jul 2021 17:43:25 +0800 Subject: [PATCH 2/3] remove redundant logic in csharp client generator --- .../languages/CSharpClientCodegen.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java index f69ffd9237fe..cab9ee837fea 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java @@ -536,33 +536,6 @@ public String getModelPropertyNaming() { return this.modelPropertyNaming; } - @Override - public Map postProcessOperationsWithModels(Map objs, List allModels) { - super.postProcessOperationsWithModels(objs, allModels); - if (objs != null) { - Map operations = (Map) objs.get("operations"); - if (operations != null) { - List ops = (List) operations.get("operation"); - for (CodegenOperation operation : ops) { - if (operation.returnType != null) { - operation.returnContainer = operation.returnType; - if (this.returnICollection && ( - operation.returnType.startsWith("List") || - operation.returnType.startsWith("Collection"))) { - // NOTE: ICollection works for both List and Collection - int genericStart = operation.returnType.indexOf("<"); - if (genericStart > 0) { - operation.returnType = "ICollection" + operation.returnType.substring(genericStart); - } - } - } - } - } - } - - return objs; - } - @Override public CodegenType getTag() { return CodegenType.CLIENT; From a5960136910dcac32d58ed407db8afcd1d74bebd Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 13 Jul 2021 20:59:18 +0800 Subject: [PATCH 3/3] update samples --- .../haskell-servant/lib/OpenAPIPetstore/API.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs index 751713adc788..e06ac16b3075 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs @@ -27,6 +27,8 @@ module OpenAPIPetstore.API , OpenAPIPetstoreClientError(..) -- ** Servant , OpenAPIPetstoreAPI + -- ** Plain WAI Application + , serverWaiApplicationOpenAPIPetstore ) where import OpenAPIPetstore.Types @@ -284,7 +286,13 @@ runOpenAPIPetstoreMiddlewareServer Config{..} middleware backend = do let warpSettings = Warp.defaultSettings & Warp.setPort (baseUrlPort url) & Warp.setHost (fromString $ baseUrlHost url) - liftIO $ Warp.runSettings warpSettings $ middleware $ serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) + liftIO $ Warp.runSettings warpSettings $ middleware $ serverWaiApplicationOpenAPIPetstore backend + +-- | Plain "Network.Wai" Application for the OpenAPIPetstore server. +-- +-- Can be used to implement e.g. tests that call the API without a full webserver. +serverWaiApplicationOpenAPIPetstore :: OpenAPIPetstoreBackend (ExceptT ServerError IO) -> Application +serverWaiApplicationOpenAPIPetstore backend = serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) where serverFromBackend OpenAPIPetstoreBackend{..} = (coerce addPet :<|>