From 58e3c1b6beae9d81a4c246362eaf8d9e11ef2910 Mon Sep 17 00:00:00 2001 From: devhl <shawnkanyer@gmail.com> Date: Fri, 28 Jan 2022 20:24:50 -0500 Subject: [PATCH 1/3] removed all nancyfx references --- .github/.test/samples.json | 12 - .github/auto-labeler.yml | 2 - README.md | 4 +- .../other/csharp-nancyfx-nancyfx-async.yaml | 7 - bin/configs/other/csharp-nancyfx-nancyfx.yaml | 7 - docs/faq-generators.md | 2 +- docs/generators.md | 1 - docs/generators/README.md | 1 - docs/generators/csharp-nancyfx.md | 209 -------- .../languages/CSharpNancyFXServerCodegen.java | 435 ----------------- .../org.openapitools.codegen.CodegenConfig | 1 - .../resources/csharp-nancyfx/Project.mustache | 79 --- .../csharp-nancyfx/Solution.mustache | 25 - .../resources/csharp-nancyfx/api.mustache | 78 --- .../main/resources/csharp-nancyfx/gitignore | 362 -------------- .../csharp-nancyfx/innerApiEnum.mustache | 10 - .../csharp-nancyfx/innerApiEnumName.mustache | 1 - .../csharp-nancyfx/innerModelEnum.mustache | 1 - .../innerParameterType.mustache | 1 - .../innerParameterValueOfArgs.mustache | 1 - .../localDateConverter.mustache | 55 --- .../resources/csharp-nancyfx/model.mustache | 15 - .../csharp-nancyfx/modelEnum.mustache | 15 - .../csharp-nancyfx/modelGeneric.mustache | 156 ------ .../csharp-nancyfx/modelMutable.mustache | 72 --- .../csharp-nancyfx/nullableDataType.mustache | 1 - .../resources/csharp-nancyfx/nuspec.mustache | 14 - .../csharp-nancyfx/packages.config.mustache | 10 - .../csharp-nancyfx/parameters.mustache | 450 ------------------ .../csharp-nancyfx/paramsList.mustache | 1 - .../server/petstore/nancyfx-async/.gitignore | 362 -------------- .../nancyfx-async/.openapi-generator-ignore | 23 - .../nancyfx-async/.openapi-generator/FILES | 16 - .../nancyfx-async/.openapi-generator/VERSION | 1 - .../nancyfx-async/Org.OpenAPITools.sln | 25 - .../src/IO.Swagger/IO.Swagger.csproj | 66 --- .../src/IO.Swagger/IO.Swagger.nuspec | 14 - .../src/IO.Swagger/Models/ApiResponse.cs | 185 ------- .../src/IO.Swagger/Models/Category.cs | 165 ------- .../src/IO.Swagger/Models/Order.cs | 247 ---------- .../src/IO.Swagger/Models/Pet.cs | 254 ---------- .../src/IO.Swagger/Models/Tag.cs | 165 ------- .../src/IO.Swagger/Models/User.cs | 285 ----------- .../src/IO.Swagger/Modules/PetModule.cs | 247 ---------- .../src/IO.Swagger/Modules/StoreModule.cs | 129 ----- .../src/IO.Swagger/Modules/UserModule.cs | 234 --------- .../IO.Swagger/Utils/LocalDateConverter.cs | 55 --- .../src/IO.Swagger/Utils/Parameters.cs | 450 ------------------ .../src/IO.Swagger/packages.config | 7 - .../Org.OpenAPITools/Models/ApiResponse.cs | 185 ------- .../src/Org.OpenAPITools/Models/Category.cs | 165 ------- .../src/Org.OpenAPITools/Models/Order.cs | 247 ---------- .../src/Org.OpenAPITools/Models/Pet.cs | 254 ---------- .../src/Org.OpenAPITools/Models/Tag.cs | 165 ------- .../src/Org.OpenAPITools/Models/User.cs | 285 ----------- .../src/Org.OpenAPITools/Modules/PetModule.cs | 250 ---------- .../Org.OpenAPITools/Modules/StoreModule.cs | 129 ----- .../Org.OpenAPITools/Modules/UserModule.cs | 234 --------- .../Org.OpenAPITools/Org.OpenAPITools.csproj | 66 --- .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 13 - .../Utils/LocalDateConverter.cs | 55 --- .../src/Org.OpenAPITools/Utils/Parameters.cs | 450 ------------------ .../src/Org.OpenAPITools/packages.config | 7 - samples/server/petstore/nancyfx/.gitignore | 362 -------------- .../nancyfx/.openapi-generator-ignore | 23 - .../petstore/nancyfx/.openapi-generator/FILES | 16 - .../nancyfx/.openapi-generator/VERSION | 1 - .../petstore/nancyfx/Org.OpenAPITools.sln | 25 - .../Org.OpenAPITools/Models/ApiResponse.cs | 185 ------- .../src/Org.OpenAPITools/Models/Category.cs | 165 ------- .../src/Org.OpenAPITools/Models/Order.cs | 247 ---------- .../src/Org.OpenAPITools/Models/Pet.cs | 254 ---------- .../src/Org.OpenAPITools/Models/Tag.cs | 165 ------- .../src/Org.OpenAPITools/Models/User.cs | 285 ----------- .../src/Org.OpenAPITools/Modules/PetModule.cs | 249 ---------- .../Org.OpenAPITools/Modules/StoreModule.cs | 128 ----- .../Org.OpenAPITools/Modules/UserModule.cs | 233 --------- .../Org.OpenAPITools/Org.OpenAPITools.csproj | 66 --- .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 13 - .../Utils/LocalDateConverter.cs | 55 --- .../src/Org.OpenAPITools/Utils/Parameters.cs | 450 ------------------ .../src/Org.OpenAPITools/packages.config | 7 - website/i18n/en.json | 4 - 83 files changed, 3 insertions(+), 10393 deletions(-) delete mode 100644 bin/configs/other/csharp-nancyfx-nancyfx-async.yaml delete mode 100644 bin/configs/other/csharp-nancyfx-nancyfx.yaml delete mode 100644 docs/generators/csharp-nancyfx.md delete mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/Project.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/Solution.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/gitignore delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnum.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnumName.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/innerModelEnum.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterType.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterValueOfArgs.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/localDateConverter.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/model.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/modelEnum.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/modelGeneric.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/modelMutable.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/nullableDataType.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/nuspec.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/packages.config.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/parameters.mustache delete mode 100644 modules/openapi-generator/src/main/resources/csharp-nancyfx/paramsList.mustache delete mode 100644 samples/server/petstore/nancyfx-async/.gitignore delete mode 100644 samples/server/petstore/nancyfx-async/.openapi-generator-ignore delete mode 100644 samples/server/petstore/nancyfx-async/.openapi-generator/FILES delete mode 100644 samples/server/petstore/nancyfx-async/.openapi-generator/VERSION delete mode 100644 samples/server/petstore/nancyfx-async/Org.OpenAPITools.sln delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.csproj delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.nuspec delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/ApiResponse.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Category.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Order.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Pet.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Tag.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/User.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/PetModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/StoreModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/UserModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/LocalDateConverter.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/Parameters.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/IO.Swagger/packages.config delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/ApiResponse.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Category.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Order.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Pet.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Tag.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/User.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/PetModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/StoreModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/UserModule.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.csproj delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.nuspec delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/LocalDateConverter.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/Parameters.cs delete mode 100644 samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/packages.config delete mode 100644 samples/server/petstore/nancyfx/.gitignore delete mode 100644 samples/server/petstore/nancyfx/.openapi-generator-ignore delete mode 100644 samples/server/petstore/nancyfx/.openapi-generator/FILES delete mode 100644 samples/server/petstore/nancyfx/.openapi-generator/VERSION delete mode 100644 samples/server/petstore/nancyfx/Org.OpenAPITools.sln delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/ApiResponse.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Category.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Order.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Pet.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Tag.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/User.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/PetModule.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/StoreModule.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/UserModule.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.csproj delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.nuspec delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/LocalDateConverter.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/Parameters.cs delete mode 100644 samples/server/petstore/nancyfx/src/Org.OpenAPITools/packages.config diff --git a/.github/.test/samples.json b/.github/.test/samples.json index d756cc45dfd..f820fc40c21 100644 --- a/.github/.test/samples.json +++ b/.github/.test/samples.json @@ -722,18 +722,6 @@ "Schema: MySQL" ] }, - { - "input": "nancyfx-petstore-server-async.sh", - "matches": [ - "Server: C-Sharp" - ] - }, - { - "input": "nancyfx-petstore-server.sh", - "matches": [ - "Server: C-Sharp" - ] - }, { "input": "nodejs-petstore-google-cloud-functions.sh", "matches": [ diff --git a/.github/auto-labeler.yml b/.github/auto-labeler.yml index 5bff51d5cec..2bb9a71d44e 100644 --- a/.github/auto-labeler.yml +++ b/.github/auto-labeler.yml @@ -223,8 +223,6 @@ labels: 'Server: C-Sharp': - '\s*?\[aspnetcore\]\s*?' - '\s*?-[gl] aspnetcore\s*?' - - '\s*?\[csharp-nancyfx\]\s*?' - - '\s*?-[gl] csharp-nancyfx\s*?' # 'Server: Ceylon': # TODO: REMOVE UNUSED LABEL 'Server: Eiffel': - '\s*?\[eiffel(-.*)?-server\]\s*?' diff --git a/README.md b/README.md index 6a23fc7554a..9f649a92c7c 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se | | Languages/Frameworks | | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0, .NET 5.0. Libraries: RestSharp, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client), **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 11.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) | -| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) | +| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) | | **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** | | **Configuration files** | [**Apache2**](https://httpd.apache.org/) | | **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** | @@ -876,6 +876,7 @@ Here is a list of template creators: * C# (.NET 2.0): @who * C# (.NET Standard 1.3 ): @Gronsak * C# (.NET 4.5 refactored): @jimschubert [:heart:](https://www.patreon.com/jimschubert) + * C# (GenericHost): @devhl-labs * C# (HttpClient): @Blackclaws * Clojure: @xhh * Crystal: @wing328 @@ -953,7 +954,6 @@ Here is a list of template creators: * C# ASP.NET Core 3.0: @A-Joshi * C# APS.NET Core 3.1: @phatcher * C# Azure functions: @Abrhm7786 - * C# NancyFX: @mstefaniuk * C++ (Qt5 QHttpEngine): @etherealjoy * C++ Pistache: @sebymiano * C++ Restbed: @stkrwork diff --git a/bin/configs/other/csharp-nancyfx-nancyfx-async.yaml b/bin/configs/other/csharp-nancyfx-nancyfx-async.yaml deleted file mode 100644 index ae5e4671753..00000000000 --- a/bin/configs/other/csharp-nancyfx-nancyfx-async.yaml +++ /dev/null @@ -1,7 +0,0 @@ -generatorName: csharp-nancyfx -outputDir: samples/server/petstore/nancyfx-async -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml -templateDir: modules/openapi-generator/src/main/resources/csharp-nancyfx -additionalProperties: - asyncServer: "true" - packageGuid: '{768B8DC6-54EE-4D40-9B20-7857E1D742A4}' diff --git a/bin/configs/other/csharp-nancyfx-nancyfx.yaml b/bin/configs/other/csharp-nancyfx-nancyfx.yaml deleted file mode 100644 index 5fd6cdffafe..00000000000 --- a/bin/configs/other/csharp-nancyfx-nancyfx.yaml +++ /dev/null @@ -1,7 +0,0 @@ -generatorName: csharp-nancyfx -outputDir: samples/server/petstore/nancyfx -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml -templateDir: modules/openapi-generator/src/main/resources/csharp-nancyfx -additionalProperties: - asyncServer: "false" - packageGuid: '{768B8DC6-54EE-4D40-9B20-7857E1D742A4}' diff --git a/docs/faq-generators.md b/docs/faq-generators.md index 7f21a93860c..370130dbe11 100644 --- a/docs/faq-generators.md +++ b/docs/faq-generators.md @@ -5,7 +5,7 @@ title: "FAQ: Generators" ### What are some server generator use cases? -We have around 40+ server generators, with more added regularly. Some of these include Spring in your choice of Java or Kotlin, the Finch and Scalatra frameworks using Scala, and C# generators for NancyFX and WebAPI (to name only a few). +We have around 40+ server generators, with more added regularly. Some of these include Spring in your choice of Java or Kotlin, the Finch and Scalatra frameworks using Scala, and C# generators for ASP.NET and Azure Functions (to name only a few). Besides generating the server code as a starting point to implement the API backend, here are some use cases of the server generators: diff --git a/docs/generators.md b/docs/generators.md index afd41cba7e3..462814d9a7f 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -86,7 +86,6 @@ The following generators are available: * [cpp-pistache-server](generators/cpp-pistache-server.md) * [cpp-qt-qhttpengine-server](generators/cpp-qt-qhttpengine-server.md) * [cpp-restbed-server](generators/cpp-restbed-server.md) -* [csharp-nancyfx](generators/csharp-nancyfx.md) * [csharp-netcore-functions (beta)](generators/csharp-netcore-functions.md) * [erlang-server](generators/erlang-server.md) * [fsharp-functions (beta)](generators/fsharp-functions.md) diff --git a/docs/generators/README.md b/docs/generators/README.md index b9e8926f664..1c8df3d2b50 100644 --- a/docs/generators/README.md +++ b/docs/generators/README.md @@ -69,7 +69,6 @@ The following generators are available: * [cpp-pistache-server](cpp-pistache-server.md) * [cpp-qt5-qhttpengine-server](cpp-qt5-qhttpengine-server.md) * [cpp-restbed-server](cpp-restbed-server.md) -* [csharp-nancyfx](csharp-nancyfx.md) * [erlang-server](erlang-server.md) * [fsharp-functions (beta)](fsharp-functions.md) * [fsharp-giraffe-server (beta)](fsharp-giraffe-server.md) diff --git a/docs/generators/csharp-nancyfx.md b/docs/generators/csharp-nancyfx.md deleted file mode 100644 index 37d2be9eb02..00000000000 --- a/docs/generators/csharp-nancyfx.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -title: Documentation for the csharp-nancyfx Generator ---- - -## METADATA - -| Property | Value | Notes | -| -------- | ----- | ----- | -| generator name | csharp-nancyfx | pass this to the generate command after -g | -| generator stability | STABLE | | -| generator type | SERVER | | -| generator language | C# | | -| generator default templating engine | mustache | | -| helpTxt | Generates a C# NancyFX Web API server. | | - -## CONFIG OPTIONS -These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. - -| Option | Description | Values | Default | -| ------ | ----------- | ------ | ------- | -|asyncServer|Set to true to enable the generation of async routes/endpoints.| |false| -|immutable|Enabled by default. If disabled generates model classes with setters| |true| -|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| || -|optionalProjectFile|Generate {PackageName}.csproj.| |true| -|packageContext|Optionally overrides the PackageContext which determines the namespace (namespace=packageName.packageContext). If not set, packageContext will default to basePath.| |null| -|packageGuid|The GUID that will be associated with the C# project| |null| -|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools| -|packageVersion|C# package version.| |1.0.0| -|returnICollection|Return ICollection<T> instead of the concrete type.| |false| -|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| -|sourceFolder|source folder for generated code| |src| -|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false| -|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false| -|writeModulePath|Enabled by default. If disabled, module paths will not mirror api base path| |true| - -## IMPORT MAPPING - -| Type/Alias | Imports | -| ---------- | ------- | - - -## INSTANTIATION TYPES - -| Type/Alias | Instantiated By | -| ---------- | --------------- | -|array|List| -|list|List| -|map|Dictionary| - - -## LANGUAGE PRIMITIVES - -<ul class="column-ul"> -<li>Boolean</li> -<li>Collection</li> -<li>DateTime</li> -<li>DateTime?</li> -<li>DateTimeOffset</li> -<li>DateTimeOffset?</li> -<li>Decimal</li> -<li>Dictionary</li> -<li>Double</li> -<li>Float</li> -<li>Guid</li> -<li>Guid?</li> -<li>ICollection</li> -<li>Int32</li> -<li>Int64</li> -<li>List</li> -<li>LocalDate?</li> -<li>LocalTime?</li> -<li>Object</li> -<li>String</li> -<li>System.IO.Stream</li> -<li>ZonedDateTime?</li> -<li>bool</li> -<li>bool?</li> -<li>byte[]</li> -<li>decimal</li> -<li>decimal?</li> -<li>double</li> -<li>double?</li> -<li>float</li> -<li>float?</li> -<li>int</li> -<li>int?</li> -<li>long</li> -<li>long?</li> -<li>string</li> -</ul> - -## RESERVED WORDS - -<ul class="column-ul"> -<li>async</li> -<li>await</li> -<li>dynamic</li> -<li>var</li> -<li>yield</li> -</ul> - -## FEATURE SET - - -### Client Modification Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|BasePath|✗|ToolingExtension -|Authorizations|✗|ToolingExtension -|UserAgent|✗|ToolingExtension -|MockServer|✗|ToolingExtension - -### Data Type Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Custom|✗|OAS2,OAS3 -|Int32|✓|OAS2,OAS3 -|Int64|✓|OAS2,OAS3 -|Float|✓|OAS2,OAS3 -|Double|✓|OAS2,OAS3 -|Decimal|✓|ToolingExtension -|String|✓|OAS2,OAS3 -|Byte|✓|OAS2,OAS3 -|Binary|✓|OAS2,OAS3 -|Boolean|✓|OAS2,OAS3 -|Date|✓|OAS2,OAS3 -|DateTime|✓|OAS2,OAS3 -|Password|✓|OAS2,OAS3 -|File|✓|OAS2 -|Array|✓|OAS2,OAS3 -|Maps|✓|ToolingExtension -|CollectionFormat|✓|OAS2 -|CollectionFormatMulti|✓|OAS2 -|Enum|✓|OAS2,OAS3 -|ArrayOfEnum|✓|ToolingExtension -|ArrayOfModel|✓|ToolingExtension -|ArrayOfCollectionOfPrimitives|✓|ToolingExtension -|ArrayOfCollectionOfModel|✓|ToolingExtension -|ArrayOfCollectionOfEnum|✓|ToolingExtension -|MapOfEnum|✓|ToolingExtension -|MapOfModel|✓|ToolingExtension -|MapOfCollectionOfPrimitives|✓|ToolingExtension -|MapOfCollectionOfModel|✓|ToolingExtension -|MapOfCollectionOfEnum|✓|ToolingExtension - -### Documentation Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Readme|✗|ToolingExtension -|Model|✓|ToolingExtension -|Api|✓|ToolingExtension - -### Global Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Host|✓|OAS2,OAS3 -|BasePath|✓|OAS2,OAS3 -|Info|✓|OAS2,OAS3 -|Schemes|✗|OAS2,OAS3 -|PartialSchemes|✓|OAS2,OAS3 -|Consumes|✓|OAS2 -|Produces|✓|OAS2 -|ExternalDocumentation|✓|OAS2,OAS3 -|Examples|✓|OAS2,OAS3 -|XMLStructureDefinitions|✗|OAS2,OAS3 -|MultiServer|✗|OAS3 -|ParameterizedServer|✗|OAS3 -|ParameterStyling|✗|OAS3 -|Callbacks|✗|OAS3 -|LinkObjects|✗|OAS3 - -### Parameter Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Path|✓|OAS2,OAS3 -|Query|✓|OAS2,OAS3 -|Header|✓|OAS2,OAS3 -|Body|✓|OAS2 -|FormUnencoded|✓|OAS2 -|FormMultipart|✓|OAS2 -|Cookie|✗|OAS3 - -### Schema Support Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Simple|✓|OAS2,OAS3 -|Composite|✓|OAS2,OAS3 -|Polymorphism|✓|OAS2,OAS3 -|Union|✗|OAS3 - -### Security Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|BasicAuth|✗|OAS2,OAS3 -|ApiKey|✗|OAS2,OAS3 -|OpenIDConnect|✗|OAS3 -|BearerToken|✗|OAS3 -|OAuth2_Implicit|✗|OAS2,OAS3 -|OAuth2_Password|✗|OAS2,OAS3 -|OAuth2_ClientCredentials|✗|OAS2,OAS3 -|OAuth2_AuthorizationCode|✗|OAS2,OAS3 - -### Wire Format Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|JSON|✓|OAS2,OAS3 -|XML|✓|OAS2,OAS3 -|PROTOBUF|✗|ToolingExtension -|Custom|✗|OAS2,OAS3 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java deleted file mode 100644 index a99243ab359..00000000000 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) - * Copyright 2018 SmartBear Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openapitools.codegen.languages; - -import com.google.common.base.Predicate; -import com.google.common.collect.*; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.Schema; -import org.openapitools.codegen.*; -import org.openapitools.codegen.meta.features.*; -import org.openapitools.codegen.utils.ModelUtils; -import org.openapitools.codegen.utils.URLPathUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.net.URL; -import java.util.*; -import java.util.Map.Entry; - -import static com.google.common.base.Strings.isNullOrEmpty; -import static java.util.Arrays.asList; -import static java.util.UUID.randomUUID; -import static org.apache.commons.lang3.StringUtils.capitalize; -import static org.openapitools.codegen.CodegenConstants.*; -import static org.openapitools.codegen.CodegenType.SERVER; -import static org.openapitools.codegen.utils.StringUtils.camelize; - -public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen { - private final Logger LOGGER = LoggerFactory.getLogger(CSharpNancyFXServerCodegen.class); - - private static final String API_NAMESPACE = "Modules"; - private static final String MODEL_NAMESPACE = "Models"; - private static final String IMMUTABLE_OPTION = "immutable"; - private static final String USE_BASE_PATH = "writeModulePath"; - private static final String PACKAGE_CONTEXT = "packageContext"; - private static final String ASYNC_SERVER = "asyncServer"; - - private static final Map<String, Predicate<Schema>> propertyToOpenAPITypeMapping = - createPropertyToOpenAPITypeMapping(); - - private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}"; - - private final Map<String, DependencyInfo> dependencies = new HashMap<>(); - private final Set<String> parentModels = new HashSet<>(); - private final Multimap<String, CodegenModel> childrenByParent = ArrayListMultimap.create(); - private final BiMap<String, String> modelNameMapping = HashBiMap.create(); - - /** - * If set to true, we will generate c# async endpoints and service interfaces - */ - private boolean asyncServer = false; - - public CSharpNancyFXServerCodegen() { - super(); - - modifyFeatureSet(features -> features - .excludeDocumentationFeatures(DocumentationFeature.Readme) - .securityFeatures(EnumSet.noneOf(SecurityFeature.class)) - .excludeGlobalFeatures( - GlobalFeature.XMLStructureDefinitions, - GlobalFeature.Callbacks, - GlobalFeature.LinkObjects, - GlobalFeature.ParameterStyling - ) - .includeSchemaSupportFeatures( - SchemaSupportFeature.Polymorphism - ) - .excludeParameterFeatures( - ParameterFeature.Cookie - ) - ); - - outputFolder = "generated-code" + File.separator + getName(); - apiTemplateFiles.put("api.mustache", ".cs"); - - // Early versions use no prefix for interfaces. Defaulting to I- common practice would break existing users. - setInterfacePrefix(""); - - // contextually reserved words - setReservedWordsLowerCase( - asList("var", "async", "await", "dynamic", "yield") - ); - - cliOptions.clear(); - - // CLI options - addOption(PACKAGE_NAME, "C# package name (convention: Title.Case).", packageName); - addOption(PACKAGE_VERSION, "C# package version.", packageVersion); - addOption(SOURCE_FOLDER, SOURCE_FOLDER_DESC, sourceFolder); - addOption(INTERFACE_PREFIX, INTERFACE_PREFIX_DESC, interfacePrefix); - addOption(OPTIONAL_PROJECT_GUID, OPTIONAL_PROJECT_GUID_DESC, null); - addOption(PACKAGE_CONTEXT, "Optionally overrides the PackageContext which determines the namespace (namespace=packageName.packageContext). If not set, packageContext will default to basePath.", null); - - // CLI Switches - addSwitch(SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_BY_REQUIRED_FLAG_DESC, sortParamsByRequiredFlag); - addSwitch(OPTIONAL_PROJECT_FILE, OPTIONAL_PROJECT_FILE_DESC, optionalProjectFileFlag); - addSwitch(USE_DATETIME_OFFSET, USE_DATETIME_OFFSET_DESC, useDateTimeOffsetFlag); - addSwitch(USE_COLLECTION, USE_COLLECTION_DESC, useCollection); - addSwitch(RETURN_ICOLLECTION, RETURN_ICOLLECTION_DESC, returnICollection); - addSwitch(IMMUTABLE_OPTION, "Enabled by default. If disabled generates model classes with setters", true); - addSwitch(USE_BASE_PATH, "Enabled by default. If disabled, module paths will not mirror api base path", true); - addSwitch(ASYNC_SERVER, "Set to true to enable the generation of async routes/endpoints.", this.asyncServer); - typeMapping.putAll(nodaTimeTypesMappings()); - languageSpecificPrimitives.addAll(nodaTimePrimitiveTypes()); - } - - @Override - public CodegenType getTag() { - return SERVER; - } - - @Override - public String getName() { - return "csharp-nancyfx"; - } - - @Override - public String getHelp() { - return "Generates a C# NancyFX Web API server."; - } - - @Override - public void processOpts() { - super.processOpts(); - - apiPackage = isNullOrEmpty(packageName) ? API_NAMESPACE : packageName + "." + API_NAMESPACE; - modelPackage = isNullOrEmpty(packageName) ? MODEL_NAMESPACE : packageName + "." + MODEL_NAMESPACE; - - supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); - supportingFiles.add(new SupportingFile("parameters.mustache", sourceFile("Utils"), "Parameters.cs")); - supportingFiles.add(new SupportingFile("localDateConverter.mustache", sourceFile("Utils"), "LocalDateConverter.cs")); - supportingFiles.add(new SupportingFile("packages.config.mustache", sourceFolder(), "packages.config")); - supportingFiles.add(new SupportingFile("nuspec.mustache", sourceFolder(), packageName + ".nuspec")); - - if (optionalProjectFileFlag) { - supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln")); - supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder(), packageName + ".csproj")); - } - - if (additionalProperties.containsKey(OPTIONAL_PROJECT_GUID)) { - setPackageGuid((String) additionalProperties.get(OPTIONAL_PROJECT_GUID)); - } - - if (additionalProperties.containsKey(ASYNC_SERVER)) { - setAsyncServer(convertPropertyToBooleanAndWriteBack(ASYNC_SERVER)); - } else { - additionalProperties.put(ASYNC_SERVER, this.asyncServer); - } - - additionalProperties.put("packageGuid", packageGuid); - - setupModelTemplate(); - processImportedMappings(); - appendDependencies(); - } - - private void setupModelTemplate() { - final Object immutableOption = additionalProperties.get(IMMUTABLE_OPTION); - if (immutableOption != null && "false".equalsIgnoreCase(immutableOption.toString())) { - LOGGER.info("Using mutable model template"); - modelTemplateFiles.put("modelMutable.mustache", ".cs"); - } else { - LOGGER.info("Using immutable model template"); - modelTemplateFiles.put("model.mustache", ".cs"); - } - } - - private void processImportedMappings() { - for (final Entry<String, String> entry : ImmutableSet.copyOf(importMapping.entrySet())) { - final String model = entry.getKey(); - final String[] namespaceInfo = entry.getValue().split("\\s"); - final String[] namespace = (namespaceInfo.length > 0 ? namespaceInfo[0].trim() : "").split(":"); - final String namespaceName = namespace.length > 0 ? namespace[0].trim() : null; - final String modelClass = namespace.length > 1 ? namespace[1].trim() : null; - final String assembly = namespaceInfo.length > 1 ? namespaceInfo[1].trim() : null; - final String assemblyVersion = namespaceInfo.length > 2 ? namespaceInfo[2].trim() : null; - final String assemblyFramework = namespaceInfo.length > 3 ? namespaceInfo[3].trim() : "net45"; - - if (isNullOrEmpty(model) || isNullOrEmpty(namespaceName)) { - LOGGER.warn(String.format(Locale.ROOT, "Could not import: '%s' - invalid namespace: '%s'", model, entry.getValue())); - importMapping.remove(model); - } else { - LOGGER.info(String.format(Locale.ROOT, "Importing: '%s' from '%s' namespace.", model, namespaceName)); - importMapping.put(model, namespaceName); - } - if (!isNullOrEmpty(modelClass)) { - LOGGER.info(String.format(Locale.ROOT, "Mapping: '%s' class to '%s'", model, modelClass)); - modelNameMapping.put(model, modelClass); - } - if (assembly != null && assemblyVersion != null) { - LOGGER.info(String.format(Locale.ROOT, "Adding dependency: '%s', version: '%s', framework: '%s'", - assembly, assemblyVersion, assemblyVersion)); - dependencies.put(assembly, new DependencyInfo(assemblyVersion, assemblyFramework)); - } - } - } - - private void appendDependencies() { - final List<Map<String, String>> listOfDependencies = new ArrayList<>(); - for (final Entry<String, DependencyInfo> dependency : dependencies.entrySet()) { - final Map<String, String> dependencyInfo = new HashMap<>(); - dependencyInfo.put("dependency", dependency.getKey()); - dependencyInfo.put("dependencyVersion", dependency.getValue().version); - dependencyInfo.put("dependencyFramework", dependency.getValue().framework); - listOfDependencies.add(dependencyInfo); - } - additionalProperties.put("dependencies", listOfDependencies); - } - - private String sourceFolder() { - return "src" + File.separator + packageName; - } - - private String sourceFile(final String fileName) { - return sourceFolder() + File.separator + fileName; - } - - public void setPackageGuid(String packageGuid) { - this.packageGuid = packageGuid; - } - - public void setAsyncServer(boolean asyncServer) { - this.asyncServer = asyncServer; - } - - @Override - public String apiFileFolder() { - return outputFolder + File.separator + sourceFolder() + File.separator + API_NAMESPACE; - } - - @Override - public String modelFileFolder() { - return outputFolder + File.separator + sourceFolder() + File.separator + MODEL_NAMESPACE; - } - - @Override - protected void processOperation(final CodegenOperation operation) { - super.processOperation(operation); - if (!isNullOrEmpty(operation.path) && operation.path.contains("?")) { - operation.path = operation.path.replace("?", "/"); - } - if (!isNullOrEmpty(operation.httpMethod)) { - operation.httpMethod = capitalize(operation.httpMethod.toLowerCase(Locale.ROOT)); - } - } - - @Override - public Map<String, Object> postProcessAllModels(final Map<String, Object> models) { - final Map<String, Object> processed = super.postProcessAllModels(models); - postProcessParentModels(models); - return processed; - } - - private void postProcessParentModels(final Map<String, Object> models) { - LOGGER.debug("Processing parents: {}", parentModels); - for (final String parent : parentModels) { - final CodegenModel parentModel = ModelUtils.getModelByName(parent, models); - if (parentModel != null) { - parentModel.hasChildren = true; - final Collection<CodegenModel> childrenModels = childrenByParent.get(parent); - for (final CodegenModel child : childrenModels) { - processParentPropertiesInChildModel(parentModel, child); - } - } - } - } - - private void processParentPropertiesInChildModel(final CodegenModel parent, final CodegenModel child) { - final Map<String, CodegenProperty> childPropertiesByName = new HashMap<>(child.vars.size()); - for (final CodegenProperty property : child.vars) { - childPropertiesByName.put(property.name, property); - } - CodegenProperty previousParentVar = null; - for (final CodegenProperty property : parent.vars) { - final CodegenProperty duplicatedByParent = childPropertiesByName.get(property.name); - if (duplicatedByParent != null) { - LOGGER.info(String.format(Locale.ROOT, "Property: '%s' in '%s' model is inherited from '%s'", - property.name, child.classname, parent.classname)); - duplicatedByParent.isInherited = true; - final CodegenProperty parentVar = duplicatedByParent.clone(); - child.parentVars.add(parentVar); - previousParentVar = parentVar; - } - } - } - - @Override - public void postProcessModelProperty(final CodegenModel model, final CodegenProperty property) { - super.postProcessModelProperty(model, property); - if (!isNullOrEmpty(model.parent)) { - parentModels.add(model.parent); - if (!childrenByParent.containsEntry(model.parent, model)) { - childrenByParent.put(model.parent, model); - } - } - } - - @Override - public String toEnumVarName(final String name, final String datatype) { - if (name.length() == 0) { - return "Empty"; - } - - final String enumName = camelize( - sanitizeName(name) - .replaceFirst("^_", "") - .replaceFirst("_$", "") - .replaceAll("-", "_")); - final String result; - if (enumName.matches("\\d.*")) { - result = "_" + enumName; - } else { - result = enumName; - } - LOGGER.debug(String.format(Locale.ROOT, "toEnumVarName('%s', %s) = '%s'", name, datatype, enumName)); - return result; - } - - @Override - public String toApiName(final String name) { - final String apiName; - if (isNullOrEmpty(name)) { - apiName = "Default"; - } else { - apiName = capitalize(name); - } - LOGGER.debug(String.format(Locale.ROOT, "toApiName('%s') = '%s'", name, apiName)); - return apiName; - } - - @Override - public String toApiFilename(final String name) { - return super.toApiFilename(name) + "Module"; - } - - @Override - public String toModelImport(final String name) { - final String result; - if (modelNameMapping.containsValue(name)) { - final String modelName = modelNameMapping.inverse().get(name); - result = importMapping.containsKey(modelName) ? - importMapping.get(modelName) : super.toModelImport(name); - } else if (importMapping.containsKey(name)) { - result = importMapping.get(name); - } else { - result = null; - } - LOGGER.debug(String.format(Locale.ROOT, "toModelImport('%s') = '%s'", name, result)); - return result; - } - - @Override - public String toModelName(final String name) { - final String modelName = super.toModelName(name); - final String mappedModelName = modelNameMapping.get(modelName); - return isNullOrEmpty(mappedModelName) ? modelName : mappedModelName; - } - - @Override - public void preprocessOpenAPI(final OpenAPI openAPI) { - URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides()); - String path = URLPathUtils.getPath(url, "/"); - final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT); - additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption); - final Object basePathOption = additionalProperties.get(USE_BASE_PATH); - additionalProperties.put("baseContext", basePathOption == null ? path : "/"); - } - - @Override - public String toEnumName(final CodegenProperty property) { - return sanitizeName(camelize(property.name)) + "Enum"; - } - - @Override - public String getSchemaType(final Schema property) { - for (Entry<String, Predicate<Schema>> entry : propertyToOpenAPITypeMapping.entrySet()) { - if (entry.getValue().apply(property)) { - return entry.getKey(); - } - } - return super.getSchemaType(property); - } - - private static Map<String, Predicate<Schema>> createPropertyToOpenAPITypeMapping() { - final ImmutableMap.Builder<String, Predicate<Schema>> mapping = ImmutableMap.builder(); - mapping.put("time", timeProperty()); - return mapping.build(); - } - - private static Predicate<Schema> timeProperty() { - return new Predicate<Schema>() { - @Override - public boolean apply(Schema property) { - return ModelUtils.isStringSchema(property) && "time".equalsIgnoreCase(property.getFormat()); - } - }; - } - - private static Map<String, String> nodaTimeTypesMappings() { - return ImmutableMap.of( - "time", "LocalTime?", - "date", "LocalDate?", - "datetime", "ZonedDateTime?"); - } - - private static Set<String> nodaTimePrimitiveTypes() { - return ImmutableSet.of("LocalTime?", "LocalDate?", "ZonedDateTime?"); - } - - private static class DependencyInfo { - private final String version; - private final String framework; - - private DependencyInfo(final String version, final String framework) { - this.version = version; - this.framework = framework; - } - } -} diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 434911baff5..427f1b8e527 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -22,7 +22,6 @@ org.openapitools.codegen.languages.CppUE4ClientCodegen org.openapitools.codegen.languages.CSharpClientCodegen org.openapitools.codegen.languages.CSharpNetCoreClientCodegen org.openapitools.codegen.languages.CSharpDotNet2ClientCodegen -org.openapitools.codegen.languages.CSharpNancyFXServerCodegen org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen org.openapitools.codegen.languages.DartClientCodegen org.openapitools.codegen.languages.DartDioClientCodegen diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/Project.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/Project.mustache deleted file mode 100644 index 0b24e4c020a..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/Project.mustache +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{{packageGuid}}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>{{packageName}}.{{packageContext}}</RootNamespace> - <AssemblyName>{{packageName}}</AssemblyName> - {{^supportsUWP}} - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - {{/supportsUWP}} - {{#supportsUWP}} - <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> - <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion> - <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion> - <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> - {{/supportsUWP}} - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Debug\{{packageName}}.XML</DocumentationFile> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Release\{{packageName}}.XML</DocumentationFile> - </PropertyGroup> - <ItemGroup> - <Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL"> - <HintPath>..\..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Sharpility, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Sharpility.1.2.2\lib\net45\Sharpility.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <HintPath>..\..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> - <Private>True</Private> - </Reference>{{#dependencies}} - <Reference Include="{{dependency}}, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\{{dependency}}.{{dependencyVersion}}\lib\{{dependencyFramework}}\{{dependency}}.dll</HintPath> - <Private>True</Private> - </Reference> - {{/dependencies}} - <Reference Include="System"/> - <Reference Include="System.Core"/> - <Reference Include="System.Xml.Linq"/> - <Reference Include="System.Data.DataSetExtensions"/> - <Reference Include="Microsoft.CSharp"/> - <Reference Include="System.Data"/> - <Reference Include="System.Runtime.Serialization"/> - <Reference Include="System.Xml"/> - </ItemGroup> - <ItemGroup> - <Compile Include="**\*.cs" Exclude="obj\**"/> - </ItemGroup> - <ItemGroup> - <Content Include="packages.config"/> - </ItemGroup> - <Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets"/> -</Project> diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/Solution.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/Solution.mustache deleted file mode 100644 index 7f2d34e366e..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/Solution.mustache +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.0.0 -MinimumVisualStudioVersion = 10.0.0.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.csproj", "{{packageGuid}}" -EndProject -Global -GlobalSection(SolutionConfigurationPlatforms) = preSolution -Debug|Any CPU = Debug|Any CPU -Release|Any CPU = Release|Any CPU -EndGlobalSection -GlobalSection(ProjectConfigurationPlatforms) = postSolution -{{packageGuid}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{{packageGuid}}.Debug|Any CPU.Build.0 = Debug|Any CPU -{{packageGuid}}.Release|Any CPU.ActiveCfg = Release|Any CPU -{{packageGuid}}.Release|Any CPU.Build.0 = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU -EndGlobalSection -GlobalSection(SolutionProperties) = preSolution -HideSolutionNode = FALSE -EndGlobalSection -EndGlobal \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache deleted file mode 100644 index c680c47a114..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using {{packageName}}.{{packageContext}}.Models; -using {{packageName}}.{{packageContext}}.Utils; -using NodaTime;{{#asyncServer}} -using System.Threading.Tasks;{{/asyncServer}} - -namespace {{packageName}}.{{packageContext}}.Modules -{ {{#operations}}{{#operation}}{{#allParams}}{{#isEnum}} - {{>innerApiEnum}}{{/isEnum}}{{/allParams}}{{/operation}} - - /// <summary> - /// Module processing requests of {{classname}} domain. - /// </summary> - public sealed class {{classname}}Module : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public {{classname}}Module({{interfacePrefix}}{{classname}}Service service) : base("{{{baseContext}}}") - { {{#operation}} - {{httpMethod}}["{{{path}}}"{{#asyncServer}}, true{{/asyncServer}}] = {{#asyncServer}}async (parameters, ct){{/asyncServer}}{{^asyncServer}}parameters{{/asyncServer}} => - { - {{#allParams}}{{#isBodyParam}}var {{paramName}} = this.Bind<{{&dataType}}>();{{/isBodyParam}}{{^isBodyParam}}{{#isEnum}}var {{paramName}} = Parameters.ValueOf<{{>innerApiEnumName}}?>({{>innerParameterValueOfArgs}});{{/isEnum}}{{^isEnum}}var {{paramName}} = Parameters.ValueOf<{{&dataType}}>({{>innerParameterValueOfArgs}});{{/isEnum}}{{^-last}} - {{/-last}}{{/isBodyParam}}{{/allParams}}{{#allParams}}{{#required}} - Preconditions.IsNotNull({{paramName}}, "Required parameter: '{{paramName}}' is missing at '{{operationId}}'"); - {{/required}}{{/allParams}} - {{#returnType}}return {{/returnType}}{{#asyncServer}}await {{/asyncServer}}service.{{operationId}}(Context{{#allParams.0}}, {{/allParams.0}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#isArray}}.ToArray(){{/isArray}}{{/returnType}};{{^returnType}} - return new Response { ContentType = "{{produces.0.mediaType}}"};{{/returnType}} - }; -{{/operation}} - } - } - - /// <summary> - /// Service handling {{classname}} requests. - /// </summary> - public interface {{interfacePrefix}}{{classname}}Service - { - {{#operation}}/// <summary> - /// {{notes}} - /// </summary> - /// <param name="context">Context of request</param> - {{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param> - {{/allParams}}/// <returns>{{returnType}}</returns> - {{#isDeprecated}} - [Obsolete] - {{/isDeprecated}} - {{#asyncServer}}{{#returnType}}Task<{{{.}}}>{{/returnType}}{{^returnType}}Task{{/returnType}}{{/asyncServer}}{{^asyncServer}}{{#returnType}}{{&returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}{{/asyncServer}} {{operationId}}(NancyContext context{{#allParams.0}}, {{/allParams.0}}{{>paramsList}});{{^-last}} - - {{/-last}}{{/operation}} - } - - /// <summary> - /// Abstraction of {{classname}}Service. - /// </summary> - public abstract class Abstract{{classname}}Service: {{interfacePrefix}}{{classname}}Service - { - {{#operation}}{{#isDeprecated}}[Obsolete] - {{/isDeprecated}}public virtual {{#asyncServer}}{{#returnType}}Task<{{{.}}}>{{/returnType}}{{^returnType}}Task{{/returnType}}{{/asyncServer}}{{^asyncServer}}{{#returnType}}{{&returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}{{/asyncServer}} {{operationId}}(NancyContext context{{#allParams.0}}, {{/allParams.0}}{{>paramsList}}) - { - {{^asyncServer}}{{#returnType}}return {{/returnType}}{{/asyncServer}}{{#asyncServer}}return {{/asyncServer}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); - }{{^-last}} - - {{/-last}}{{/operation}} - - {{#operation}}{{#isDeprecated}}[Obsolete] - {{/isDeprecated}}protected abstract {{#asyncServer}}{{#returnType}}Task<{{{.}}}>{{/returnType}}{{^returnType}}Task{{/returnType}}{{/asyncServer}}{{^asyncServer}}{{#returnType}}{{&returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}{{/asyncServer}} {{operationId}}({{>paramsList}});{{^-last}} - - {{/-last}}{{/operation}} - } - -{{/operations}} -} diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/gitignore b/modules/openapi-generator/src/main/resources/csharp-nancyfx/gitignore deleted file mode 100644 index 1ee53850b84..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/gitignore +++ /dev/null @@ -1,362 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnum.mustache deleted file mode 100644 index eb456ababf9..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnum.mustache +++ /dev/null @@ -1,10 +0,0 @@ -/// <summary> - /// {{description}}{{^description}}{{classname}}{{/description}} - /// </summary> - public enum {{>innerApiEnumName}} - { - {{#allowableValues}} -{{#values}} {{&.}}{{^isInteger}} = {{-index}}{{/isInteger}}{{^-last}}, {{/-last}} -{{/values}} - {{/allowableValues}} - }; diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnumName.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnumName.mustache deleted file mode 100644 index f2b90daa144..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerApiEnumName.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#datatypeWithEnum}}{{operationId}}{{^isContainer}}{{.}}{{/isContainer}}{{#isContainer}}{{{items.datatypeWithEnum}}}{{/isContainer}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerModelEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerModelEnum.mustache deleted file mode 100644 index 3fd8e401dcf..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerModelEnum.mustache +++ /dev/null @@ -1 +0,0 @@ -public enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#allowableValues}}{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} }; \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterType.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterType.mustache deleted file mode 100644 index c9a8cb66449..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterType.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isQueryParam}}ParameterType.Query{{/isQueryParam}}{{#isPathParam}}ParameterType.Path{{/isPathParam}}{{#isHeaderParam}}ParameterType.Header{{/isHeaderParam}}{{^isQueryParam}}{{^isPathParam}}{{^isHeaderParam}}ParameterType.Undefined{{/isHeaderParam}}{{/isPathParam}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterValueOfArgs.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterValueOfArgs.mustache deleted file mode 100644 index 2aca302eecf..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/innerParameterValueOfArgs.mustache +++ /dev/null @@ -1 +0,0 @@ -parameters, Context.Request, "{{paramName}}", {{>innerParameterType}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/localDateConverter.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/localDateConverter.mustache deleted file mode 100644 index d709c22cc1b..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/localDateConverter.mustache +++ /dev/null @@ -1,55 +0,0 @@ -using Nancy.Bootstrapper; -using Nancy.Json; -using NodaTime; -using NodaTime.Text; -using System; -using System.Collections.Generic; - -namespace {{packageName}}.{{packageContext}}.Utils -{ - /// <summary> - /// (De)serializes a <see cref="NodaTime.LocalDate"/> to a string using - /// the <a href="https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14">RFC3339</a> - /// <code>full-date</code> format. - /// </summary> - public class LocalDateConverter : JavaScriptPrimitiveConverter, IApplicationStartup - { - public override IEnumerable<Type> SupportedTypes - { - get - { - yield return typeof(LocalDate); - yield return typeof(LocalDate?); - } - } - - public void Initialize(IPipelines pipelines) - { - JsonSettings.PrimitiveConverters.Add(new LocalDateConverter()); - } - - - public override object Serialize(object obj, JavaScriptSerializer serializer) - { - if (obj is LocalDate) - { - LocalDate localDate = (LocalDate)obj; - return LocalDatePattern.IsoPattern.Format(localDate); - } - return null; - } - - public override object Deserialize(object primitiveValue, Type type, JavaScriptSerializer serializer) - { - if ((type == typeof(LocalDate) || type == typeof(LocalDate?)) && primitiveValue is string) - { - try - { - return LocalDatePattern.IsoPattern.Parse(primitiveValue as string).GetValueOrThrow(); - } - catch { } - } - return null; - } - } -} diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/model.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/model.mustache deleted file mode 100644 index 7765632abdb..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/model.mustache +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace {{packageName}}.{{packageContext}}.Models -{ -{{#models}} -{{#model}} -{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}} -{{/model}} -{{/models}} -} diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelEnum.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelEnum.mustache deleted file mode 100644 index 01c5ec32aa1..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelEnum.mustache +++ /dev/null @@ -1,15 +0,0 @@ - /// <summary> - /// {{description}}{{^description}}Defines {{{name}}}{{/description}} - /// </summary> - {{#description}} - /// <value>{{.}}</value> - {{/description}} - public enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} - { - {{#allowableValues}}{{#enumVars}} - /// <summary> - /// Enum {{name}} - /// </summary> - {{name}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^isInteger}} = {{-index}}{{/isInteger}}{{^-last}}, - {{/-last}}{{/enumVars}}{{/allowableValues}} - } diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelGeneric.mustache deleted file mode 100644 index 8bb564a7971..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelGeneric.mustache +++ /dev/null @@ -1,156 +0,0 @@ - /// <summary> - /// {{description}}{{^description}}{{classname}}{{/description}} - /// </summary> - public {{^hasChildren}}sealed {{/hasChildren}}class {{classname}}: {{#parent}}{{{.}}}, {{/parent}} IEquatable<{{classname}}> - { {{#vars}}{{^isInherited}} - /// <summary> - /// {{description}}{{^description}}{{{name}}}{{/description}} - /// </summary> - public {{>nullableDataType}} {{name}} { get; private set; } -{{/isInherited}}{{/vars}} - - /// <summary> - /// Empty constructor required by some serializers. - /// Use {{classname}}.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public {{classname}}(){{#parent}} : base({{/parent}}{{#parentVars}}null{{^-last}}, {{/-last}}{{/parentVars}}{{#parent}}){{/parent}} - { - } - - {{#hasChildren}}protected{{/hasChildren}}{{^hasChildren}}private{{/hasChildren}} {{classname}}({{#vars}}{{>nullableDataType}} {{name}}{{^-last}}, {{/-last}}{{/vars}}){{#parent}} : base({{#parentVars}}{{name}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}} - { - {{#vars}}{{^isInherited}} - this.{{name}} = {{name}}; - {{/isInherited}}{{/vars}} - } - - /// <summary> - /// Returns builder of {{classname}}. - /// </summary> - /// <returns>{{classname}}Builder</returns> - public static {{#parent}}new {{/parent}}{{classname}}Builder Builder() - { - return new {{classname}}Builder(); - } - - /// <summary> - /// Returns {{classname}}Builder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>{{classname}}Builder</returns> - public {{#parent}}new {{/parent}}{{classname}}Builder With() - { - return Builder() - {{#vars}} - .{{name}}({{name}}){{^-last}} -{{/-last}}{{/vars}}; - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals({{classname}} other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for ({{classname}}. - /// </summary> - /// <param name="left">Compared ({{classname}}</param> - /// <param name="right">Compared ({{classname}}</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == ({{classname}} left, {{classname}} right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for ({{classname}}. - /// </summary> - /// <param name="left">Compared ({{classname}}</param> - /// <param name="right">Compared ({{classname}}</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != ({{classname}} left, {{classname}} right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of {{classname}}. - /// </summary> - public sealed class {{classname}}Builder - { - {{#vars}} - private {{>nullableDataType}} _{{name}}; - {{/vars}} - - internal {{classname}}Builder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - {{#vars}} - {{^required}} - {{#defaultValue}} - _{{name}} = {{{defaultValue}}}; - {{/defaultValue}} - {{/required}} - {{/vars}} - } - - {{#vars}} - /// <summary> - /// Sets value for {{classname}}.{{{name}}} property. - /// </summary> - /// <param name="value">{{description}}{{^description}}{{{name}}}{{/description}}</param> - public {{classname}}Builder {{name}}({{>nullableDataType}} value) - { - _{{name}} = value; - return this; - } - - {{/vars}} - - /// <summary> - /// Builds instance of {{classname}}. - /// </summary> - /// <returns>{{classname}}</returns> - public {{classname}} Build() - { - Validate(); - return new {{classname}}( - {{#vars}} - {{name}}: _{{name}}{{^-last}},{{/-last}} - {{/vars}} - ); - } - - private void Validate() - { {{#vars}}{{#required}} - if (_{{name}} == null) - { - throw new ArgumentException("{{name}} is a required property for {{classname}} and cannot be null"); - } {{/required}}{{/vars}} - } - } - - {{#vars}}{{#isEnum}}{{^parent}} - {{>innerModelEnum}}{{/parent}}{{/isEnum}}{{#items.isEnum}} - {{#items}}{{>innerModelEnum}}{{/items}}{{/items.isEnum}}{{/vars}} - } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelMutable.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelMutable.mustache deleted file mode 100644 index 3ab64e3b06e..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/modelMutable.mustache +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; -{{#imports}}using {{import}}; -{{/imports}} - -{{#models}} -{{#model}} -namespace {{packageName}}.{{packageContext}}.Models -{ {{#vars}}{{#isEnum}}{{^parent}} - {{>innerModelEnum}}{{/parent}}{{/isEnum}}{{#items.isEnum}} - {{#items}}{{>innerModelEnum}}{{/items}}{{/items.isEnum}}{{/vars}} - -/// <summary> - /// {{description}}{{^description}}{{classname}}{{/description}} - /// </summary> - public {{^hasChildren}}sealed {{/hasChildren}}class {{classname}}: {{#parent}}{{{.}}}, {{/parent}} IEquatable<{{classname}}> - { {{#vars}}{{^isInherited}} - /// <summary> - /// {{description}}{{^description}}{{{name}}}{{/description}} - /// </summary> - public {{>nullableDataType}} {{name}} { get; set; } -{{/isInherited}}{{/vars}} - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals({{classname}} other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for ({{classname}}. - /// </summary> - /// <param name="left">Compared ({{classname}}</param> - /// <param name="right">Compared ({{classname}}</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == ({{classname}} left, {{classname}} right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for ({{classname}}. - /// </summary> - /// <param name="left">Compared ({{classname}}</param> - /// <param name="right">Compared ({{classname}}</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != ({{classname}} left, {{classname}} right) - { - return !Equals(left, right); - } - } -{{/model}} -{{/models}} -} diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/nullableDataType.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/nullableDataType.mustache deleted file mode 100644 index c999b870119..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/nullableDataType.mustache +++ /dev/null @@ -1 +0,0 @@ -{{&datatypeWithEnum}}{{#isEnum}}?{{/isEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/nuspec.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/nuspec.mustache deleted file mode 100644 index 65912590d19..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/nuspec.mustache +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<package> - <metadata> - <id>{{packageName}}</id> - <title>{{packageName}}</title> - <version>{{{version}}}</version> - <authors>openapi-generator</authors> - <owners>openapi-generator</owners> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>NancyFx {{packageName}} API</description>{{#termsOfService}} - <copyright>{{.}}</copyright>{{/termsOfService}}{{#licenseUrl}} - <licenseUrl>{{.}}</licenseUrl>{{/licenseUrl}} - </metadata> -</package> \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/packages.config.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/packages.config.mustache deleted file mode 100644 index c511c50acc8..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/packages.config.mustache +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="Nancy" version="1.4.3" targetFramework="net45" /> - <package id="NodaTime" version="1.3.1" targetFramework="net45" /> - <package id="Sharpility" version="1.2.2" targetFramework="net45" /> - <package id="System.Collections.Immutable" version="1.1.37" targetFramework="net45" /> - {{#dependencies}} - <package id="{{dependency}}" version="{{dependencyVersion}}" targetFramework="{{dependencyFramework}}" /> - {{/dependencies}} -</packages> \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/parameters.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/parameters.mustache deleted file mode 100644 index 61caaf25f56..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/parameters.mustache +++ /dev/null @@ -1,450 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Nancy; -using NodaTime; -using NodaTime.Text; -using Sharpility.Base; -using Sharpility.Extensions; -using Sharpility.Util; - -namespace {{packageName}}.{{packageContext}}.Utils -{ - internal static class Parameters - { - private static readonly IDictionary<Type, Func<Parameter, object>> Parsers = CreateParsers(); - - internal static TValue ValueOf<TValue>(dynamic parameters, Request request, string name, ParameterType parameterType) - { - var valueType = typeof(TValue); - var valueUnderlyingType = Nullable.GetUnderlyingType(valueType); - var isNullable = default(TValue) == null; - string value = RawValueOf(parameters, request, name, parameterType); - Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name)); - if (value == null && isNullable) - { - return default(TValue); - } - if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum)) - { - return EnumValueOf<TValue>(name, value); - } - return ValueOf<TValue>(parameters, name, value, valueType, request, parameterType); - } - - private static string RawValueOf(dynamic parameters, Request request, string name, ParameterType parameterType) - { - try - { - switch (parameterType) - { - case ParameterType.Query: - string querValue = request.Query[name]; - return querValue; - case ParameterType.Path: - string pathValue = parameters[name]; - return pathValue; - case ParameterType.Header: - var headerValue = request.Headers[name]; - return headerValue != null ? string.Join(",", headerValue) : null; - } - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not obtain value of '{0}' parameter", name), e); - } - throw new InvalidOperationException(string.Format("Parameter with type: {0} is not supported", parameterType)); - } - - private static TValue EnumValueOf<TValue>(string name, string value) - { - var valueType = typeof(TValue); - var enumType = valueType.IsEnum ? valueType : Nullable.GetUnderlyingType(valueType); - Preconditions.IsNotNull(enumType, () => new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' to enum. Type {1} is not enum", name, valueType))); - var values = Enum.GetValues(enumType); - foreach (var entry in values) - { - if (entry.ToString().EqualsIgnoreCases(value) - || ((int)entry).ToString().EqualsIgnoreCases(value)) - { - return (TValue)entry; - } - } - throw new ArgumentException(string.Format("Parameter: '{0}' value: '{1}' is not supported. Expected one of: {2}", - name, value, Strings.ToString(values))); - } - - private static TValue ValueOf<TValue>(dynamic parameters, string name, string value, Type valueType, Request request, ParameterType parameterType) - { - var parser = Parsers.GetIfPresent(valueType); - if (parser != null) - { - return ParseValueUsing<TValue>(name, value, valueType, parser); - } - if (parameterType == ParameterType.Path) - { - return DynamicValueOf<TValue>(parameters, name); - } - if (parameterType == ParameterType.Query) - { - return DynamicValueOf<TValue>(request.Query, name); - } - throw new InvalidOperationException(string.Format("Could not get value for {0} with type {1}", name, valueType)); - } - - private static TValue ParseValueUsing<TValue>(string name, string value, Type valueType, Func<Parameter, object> parser) - { - var result = parser(Parameter.Of(name, value)); - try - { - return (TValue)result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' with value: '{1}'. " + - "Received: '{2}', expected: '{3}'.", - name, value, result.GetType(), valueType)); - } - } - - private static TValue DynamicValueOf<TValue>(dynamic parameters, string name) - { - string value = parameters[name]; - try - { - TValue result = parameters[name]; - return result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException(Strings.Format("Parameter: '{0}' value: '{1}' could not be parsed. " + - "Expected type: '{2}' is not supported", - name, value, typeof(TValue))); - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not get '{0}' value of '{1}' type dynamically", - name, typeof(TValue)), e); - } - } - - private static IDictionary<Type, Func<Parameter, object>> CreateParsers() - { - var parsers = ImmutableDictionary.CreateBuilder<Type, Func<Parameter, object>>(); - parsers.Put(typeof(string), value => value.Value); - parsers.Put(typeof(bool), SafeParse(bool.Parse)); - parsers.Put(typeof(bool?), SafeParse(bool.Parse)); - parsers.Put(typeof(byte), SafeParse(byte.Parse)); - parsers.Put(typeof(sbyte?), SafeParse(sbyte.Parse)); - parsers.Put(typeof(short), SafeParse(short.Parse)); - parsers.Put(typeof(short?), SafeParse(short.Parse)); - parsers.Put(typeof(ushort), SafeParse(ushort.Parse)); - parsers.Put(typeof(ushort?), SafeParse(ushort.Parse)); - parsers.Put(typeof(int), SafeParse(int.Parse)); - parsers.Put(typeof(int?), SafeParse(int.Parse)); - parsers.Put(typeof(uint), SafeParse(uint.Parse)); - parsers.Put(typeof(uint?), SafeParse(uint.Parse)); - parsers.Put(typeof(long), SafeParse(long.Parse)); - parsers.Put(typeof(long?), SafeParse(long.Parse)); - parsers.Put(typeof(ulong), SafeParse(ulong.Parse)); - parsers.Put(typeof(ulong?), SafeParse(ulong.Parse)); - parsers.Put(typeof(float), SafeParse(float.Parse)); - parsers.Put(typeof(float?), SafeParse(float.Parse)); - parsers.Put(typeof(double), SafeParse(double.Parse)); - parsers.Put(typeof(double?), SafeParse(double.Parse)); - parsers.Put(typeof(decimal), SafeParse(decimal.Parse)); - parsers.Put(typeof(decimal?), SafeParse(decimal.Parse)); - parsers.Put(typeof(DateTime), SafeParse(DateTime.Parse)); - parsers.Put(typeof(DateTime?), SafeParse(DateTime.Parse)); - parsers.Put(typeof(TimeSpan), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(TimeSpan?), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(ZonedDateTime), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(ZonedDateTime?), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(LocalDate), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalDate?), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalTime), SafeParse(ParseLocalTime)); - parsers.Put(typeof(LocalTime?), SafeParse(ParseLocalTime)); - - parsers.Put(typeof(IEnumerable<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(ICollection<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(IList<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(List<string>), ListParse(value => value)); - parsers.Put(typeof(ISet<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(HashSet<string>), SetParse(value => value)); - - parsers.Put(typeof(IEnumerable<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(ICollection<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(IList<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(List<bool?>), NullableListParse(bool.Parse)); - parsers.Put(typeof(ISet<bool?>), NullableImmutableSetParse(bool.Parse)); - parsers.Put(typeof(HashSet<bool?>), NullableSetParse(bool.Parse)); - - parsers.Put(typeof(IEnumerable<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(ICollection<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(IList<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(List<byte>), ListParse(byte.Parse)); - parsers.Put(typeof(ISet<byte>), ImmutableSetParse(byte.Parse)); - parsers.Put(typeof(HashSet<byte>), SetParse(byte.Parse)); - - parsers.Put(typeof(IEnumerable<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(ICollection<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(IList<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(List<sbyte>), ListParse(sbyte.Parse)); - parsers.Put(typeof(ISet<sbyte>), ImmutableSetParse(sbyte.Parse)); - parsers.Put(typeof(HashSet<sbyte>), SetParse(sbyte.Parse)); - - parsers.Put(typeof(IEnumerable<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(ICollection<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(IList<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(List<short>), ListParse(short.Parse)); - parsers.Put(typeof(ISet<short>), ImmutableSetParse(short.Parse)); - parsers.Put(typeof(HashSet<short>), SetParse(short.Parse)); - - parsers.Put(typeof(IEnumerable<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(ICollection<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(IList<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(List<ushort>), ListParse(ushort.Parse)); - parsers.Put(typeof(ISet<ushort>), ImmutableSetParse(ushort.Parse)); - parsers.Put(typeof(HashSet<ushort>), SetParse(ushort.Parse)); - - parsers.Put(typeof(IEnumerable<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(ICollection<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(IList<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(List<int?>), NullableListParse(int.Parse)); - parsers.Put(typeof(ISet<int?>), NullableImmutableSetParse(int.Parse)); - parsers.Put(typeof(HashSet<int?>), NullableSetParse(int.Parse)); - - parsers.Put(typeof(IEnumerable<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(ICollection<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(IList<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(List<uint>), ListParse(uint.Parse)); - parsers.Put(typeof(ISet<uint>), ImmutableSetParse(uint.Parse)); - parsers.Put(typeof(HashSet<uint>), SetParse(uint.Parse)); - - parsers.Put(typeof(IEnumerable<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(ICollection<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(IList<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(List<long?>), NullableListParse(long.Parse)); - parsers.Put(typeof(ISet<long?>), NullableImmutableSetParse(long.Parse)); - parsers.Put(typeof(HashSet<long?>), NullableSetParse(long.Parse)); - - parsers.Put(typeof(IEnumerable<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(ICollection<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(IList<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(List<ulong>), ListParse(ulong.Parse)); - parsers.Put(typeof(ISet<ulong>), ImmutableSetParse(ulong.Parse)); - parsers.Put(typeof(HashSet<ulong>), SetParse(ulong.Parse)); - - parsers.Put(typeof(IEnumerable<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(ICollection<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(IList<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(List<float?>), NullableListParse(float.Parse)); - parsers.Put(typeof(ISet<float?>), NullableImmutableSetParse(float.Parse)); - parsers.Put(typeof(HashSet<float?>), NullableSetParse(float.Parse)); - - parsers.Put(typeof(IEnumerable<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(ICollection<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(IList<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(List<double?>), NullableListParse(double.Parse)); - parsers.Put(typeof(ISet<double?>), NullableImmutableSetParse(double.Parse)); - parsers.Put(typeof(HashSet<double?>), NullableSetParse(double.Parse)); - - parsers.Put(typeof(IEnumerable<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(ICollection<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(IList<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(List<decimal?>), NullableListParse(decimal.Parse)); - parsers.Put(typeof(ISet<decimal?>), NullableImmutableSetParse(decimal.Parse)); - parsers.Put(typeof(HashSet<decimal?>), NullableSetParse(decimal.Parse)); - - parsers.Put(typeof(IEnumerable<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(ICollection<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(IList<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(List<DateTime?>), NullableListParse(DateTime.Parse)); - parsers.Put(typeof(ISet<DateTime?>), NullableImmutableSetParse(DateTime.Parse)); - parsers.Put(typeof(HashSet<DateTime?>), NullableSetParse(DateTime.Parse)); - - parsers.Put(typeof(IEnumerable<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(ICollection<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(IList<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(List<TimeSpan>), ListParse(TimeSpan.Parse)); - parsers.Put(typeof(ISet<TimeSpan>), ImmutableSetParse(TimeSpan.Parse)); - parsers.Put(typeof(HashSet<TimeSpan>), SetParse(TimeSpan.Parse)); - - return parsers.ToImmutableDictionary(); - } - - private static Func<Parameter, object> SafeParse<T>(Func<string, T> parse) - { - return parameter => - { - try - { - return parse(parameter.Value); - } - catch (OverflowException) - { - throw ParameterOutOfRange(parameter, typeof(T)); - } - catch (FormatException) - { - throw InvalidParameterFormat(parameter, typeof(T)); - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse parameter: '{0}' with value: '{1}' to {2}", - parameter.Name, parameter.Value, typeof(T)), e); - } - }; - } - - private static Func<Parameter, object> NullableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new List<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToList(); - }; - } - - private static Func<Parameter, object> NullableImmutableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Lists.EmptyList<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableList(); - }; - } - - private static Func<Parameter, object> NullableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return SetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> SetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new HashSet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToSet(); - }; - } - - private static Func<Parameter, object> NullableImmutableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableSetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableSetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Sets.EmptySet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableHashSet(); - }; - } - - private static ZonedDateTime ParseZonedDateTime(string value) - { - var dateTime = DateTime.Parse(value); - return new ZonedDateTime(Instant.FromDateTimeUtc(dateTime.ToUniversalTime()), DateTimeZone.Utc); - } - - private static LocalDate ParseLocalDate(string value) - { - return LocalDatePattern.IsoPattern.Parse(value).Value; - } - - private static LocalTime ParseLocalTime(string value) - { - return LocalTimePattern.ExtendedIsoPattern.Parse(value).Value; - } - - private static ArgumentException ParameterOutOfRange(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query: '{0}' value: '{1}' is out of range for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static ArgumentException InvalidParameterFormat(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query '{0}' value: '{1}' format is invalid for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static IEnumerable<T> ParseCollection<T>(string value, Func<string, T> itemParser) - { - var results = value.Split(new[] { ',' }, StringSplitOptions.None) - .Where(it => it != null) - .Select(it => it.Trim()) - .Select(itemParser); - return results; - } - - public static T? ToNullable<T>(this string s, Func<string, T> itemParser) where T : struct - { - T? result = new T?(); - try - { - if (!string.IsNullOrEmpty(s) && s.Trim().Length > 0) - { - result = itemParser(s); - } - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse value: '{0}' to nullable: '{1}'", s, typeof(T).ToString()), e); - } - return result; - } - - private class Parameter - { - internal string Name { get; private set; } - internal string Value { get; private set; } - - private Parameter(string name, string value) - { - Name = name; - Value = value; - } - - internal static Parameter Of(string name, string value) - { - return new Parameter(name, value); - } - } - } - - internal enum ParameterType - { - Undefined, - Query, - Path, - Header - } -} diff --git a/modules/openapi-generator/src/main/resources/csharp-nancyfx/paramsList.mustache b/modules/openapi-generator/src/main/resources/csharp-nancyfx/paramsList.mustache deleted file mode 100644 index 47e502dded9..00000000000 --- a/modules/openapi-generator/src/main/resources/csharp-nancyfx/paramsList.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#allParams}}{{#isEnum}}{{>innerApiEnumName}}?{{/isEnum}}{{^isEnum}}{{&dataType}}{{/isEnum}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/.gitignore b/samples/server/petstore/nancyfx-async/.gitignore deleted file mode 100644 index 1ee53850b84..00000000000 --- a/samples/server/petstore/nancyfx-async/.gitignore +++ /dev/null @@ -1,362 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd diff --git a/samples/server/petstore/nancyfx-async/.openapi-generator-ignore b/samples/server/petstore/nancyfx-async/.openapi-generator-ignore deleted file mode 100644 index c5fa491b4c5..00000000000 --- a/samples/server/petstore/nancyfx-async/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/samples/server/petstore/nancyfx-async/.openapi-generator/FILES b/samples/server/petstore/nancyfx-async/.openapi-generator/FILES deleted file mode 100644 index eabec10a061..00000000000 --- a/samples/server/petstore/nancyfx-async/.openapi-generator/FILES +++ /dev/null @@ -1,16 +0,0 @@ -.gitignore -Org.OpenAPITools.sln -src/Org.OpenAPITools/Models/ApiResponse.cs -src/Org.OpenAPITools/Models/Category.cs -src/Org.OpenAPITools/Models/Order.cs -src/Org.OpenAPITools/Models/Pet.cs -src/Org.OpenAPITools/Models/Tag.cs -src/Org.OpenAPITools/Models/User.cs -src/Org.OpenAPITools/Modules/PetModule.cs -src/Org.OpenAPITools/Modules/StoreModule.cs -src/Org.OpenAPITools/Modules/UserModule.cs -src/Org.OpenAPITools/Org.OpenAPITools.csproj -src/Org.OpenAPITools/Org.OpenAPITools.nuspec -src/Org.OpenAPITools/Utils/LocalDateConverter.cs -src/Org.OpenAPITools/Utils/Parameters.cs -src/Org.OpenAPITools/packages.config diff --git a/samples/server/petstore/nancyfx-async/.openapi-generator/VERSION b/samples/server/petstore/nancyfx-async/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/server/petstore/nancyfx-async/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/Org.OpenAPITools.sln b/samples/server/petstore/nancyfx-async/Org.OpenAPITools.sln deleted file mode 100644 index 757078a1383..00000000000 --- a/samples/server/petstore/nancyfx-async/Org.OpenAPITools.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.0.0 -MinimumVisualStudioVersion = 10.0.0.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{768B8DC6-54EE-4D40-9B20-7857E1D742A4}" -EndProject -Global -GlobalSection(SolutionConfigurationPlatforms) = preSolution -Debug|Any CPU = Debug|Any CPU -Release|Any CPU = Release|Any CPU -EndGlobalSection -GlobalSection(ProjectConfigurationPlatforms) = postSolution -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Debug|Any CPU.Build.0 = Debug|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Release|Any CPU.ActiveCfg = Release|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Release|Any CPU.Build.0 = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU -EndGlobalSection -GlobalSection(SolutionProperties) = preSolution -HideSolutionNode = FALSE -EndGlobalSection -EndGlobal \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.csproj b/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.csproj deleted file mode 100644 index e1577197b6f..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.csproj +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{768B8DC6-54EE-4D40-9B20-7857E1D742A4}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>IO.Swagger.v2</RootNamespace> - <AssemblyName>IO.Swagger</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Debug\IO.Swagger.XML</DocumentationFile> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Release\IO.Swagger.XML</DocumentationFile> - </PropertyGroup> - <ItemGroup> - <Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL"> - <HintPath>..\..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Sharpility, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Sharpility.1.2.2\lib\net45\Sharpility.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <HintPath>..\..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="System"/> - <Reference Include="System.Core"/> - <Reference Include="System.Xml.Linq"/> - <Reference Include="System.Data.DataSetExtensions"/> - <Reference Include="Microsoft.CSharp"/> - <Reference Include="System.Data"/> - <Reference Include="System.Runtime.Serialization"/> - <Reference Include="System.Xml"/> - </ItemGroup> - <ItemGroup> - <Compile Include="**\*.cs" Exclude="obj\**"/> - </ItemGroup> - <ItemGroup> - <Content Include="packages.config"/> - </ItemGroup> - <Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets"/> -</Project> - diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.nuspec b/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.nuspec deleted file mode 100644 index 360effbaf7f..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/IO.Swagger.nuspec +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<package> - <metadata> - <id>IO.Swagger</id> - <title>IO.Swagger</title> - <version>1.0.0</version> - <authors>swagger-codegen</authors> - <owners>swagger-codegen</owners> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>NancyFx IO.Swagger API</description> - <copyright>http://swagger.io/terms/</copyright> - <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> - </metadata> -</package> \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/ApiResponse.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/ApiResponse.cs deleted file mode 100644 index ebaa3c8d4f1..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/ApiResponse.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// Describes the result of uploading an image resource - /// </summary> - public sealed class ApiResponse: IEquatable<ApiResponse> - { - /// <summary> - /// Code - /// </summary> - public int? Code { get; private set; } - - /// <summary> - /// Type - /// </summary> - public string Type { get; private set; } - - /// <summary> - /// Message - /// </summary> - public string Message { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use ApiResponse.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public ApiResponse() - { - } - - private ApiResponse(int? Code, string Type, string Message) - { - - this.Code = Code; - - this.Type = Type; - - this.Message = Message; - - } - - /// <summary> - /// Returns builder of ApiResponse. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public static ApiResponseBuilder Builder() - { - return new ApiResponseBuilder(); - } - - /// <summary> - /// Returns ApiResponseBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public ApiResponseBuilder With() - { - return Builder() - .Code(Code) - .Type(Type) - .Message(Message); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(ApiResponse other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (ApiResponse left, ApiResponse right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (ApiResponse left, ApiResponse right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of ApiResponse. - /// </summary> - public sealed class ApiResponseBuilder - { - private int? _Code; - private string _Type; - private string _Message; - - internal ApiResponseBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for ApiResponse.Code property. - /// </summary> - /// <param name="value">Code</param> - public ApiResponseBuilder Code(int? value) - { - _Code = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Type property. - /// </summary> - /// <param name="value">Type</param> - public ApiResponseBuilder Type(string value) - { - _Type = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Message property. - /// </summary> - /// <param name="value">Message</param> - public ApiResponseBuilder Message(string value) - { - _Message = value; - return this; - } - - - /// <summary> - /// Builds instance of ApiResponse. - /// </summary> - /// <returns>ApiResponse</returns> - public ApiResponse Build() - { - Validate(); - return new ApiResponse( - Code: _Code, - Type: _Type, - Message: _Message - ); - } - - private void Validate() - { - } - } - - - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Category.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Category.cs deleted file mode 100644 index bf811614b37..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Category.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// A category for a pet - /// </summary> - public sealed class Category: IEquatable<Category> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Category.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Category() - { - } - - private Category(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Category. - /// </summary> - /// <returns>CategoryBuilder</returns> - public static CategoryBuilder Builder() - { - return new CategoryBuilder(); - } - - /// <summary> - /// Returns CategoryBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>CategoryBuilder</returns> - public CategoryBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Category other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Category left, Category right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Category left, Category right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Category. - /// </summary> - public sealed class CategoryBuilder - { - private long? _Id; - private string _Name; - - internal CategoryBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Category.Id property. - /// </summary> - /// <param name="value">Id</param> - public CategoryBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Category.Name property. - /// </summary> - /// <param name="value">Name</param> - public CategoryBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Category. - /// </summary> - /// <returns>Category</returns> - public Category Build() - { - Validate(); - return new Category( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Order.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Order.cs deleted file mode 100644 index 0495a36f138..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Order.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// An order for a pets from the pet store - /// </summary> - public sealed class Order: IEquatable<Order> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// PetId - /// </summary> - public long? PetId { get; private set; } - - /// <summary> - /// Quantity - /// </summary> - public int? Quantity { get; private set; } - - /// <summary> - /// ShipDate - /// </summary> - public ZonedDateTime? ShipDate { get; private set; } - - /// <summary> - /// Order Status - /// </summary> - public StatusEnum? Status { get; private set; } - - /// <summary> - /// Complete - /// </summary> - public bool? Complete { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Order.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Order() - { - } - - private Order(long? Id, long? PetId, int? Quantity, ZonedDateTime? ShipDate, StatusEnum? Status, bool? Complete) - { - - this.Id = Id; - - this.PetId = PetId; - - this.Quantity = Quantity; - - this.ShipDate = ShipDate; - - this.Status = Status; - - this.Complete = Complete; - - } - - /// <summary> - /// Returns builder of Order. - /// </summary> - /// <returns>OrderBuilder</returns> - public static OrderBuilder Builder() - { - return new OrderBuilder(); - } - - /// <summary> - /// Returns OrderBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>OrderBuilder</returns> - public OrderBuilder With() - { - return Builder() - .Id(Id) - .PetId(PetId) - .Quantity(Quantity) - .ShipDate(ShipDate) - .Status(Status) - .Complete(Complete); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Order other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Order left, Order right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Order left, Order right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Order. - /// </summary> - public sealed class OrderBuilder - { - private long? _Id; - private long? _PetId; - private int? _Quantity; - private ZonedDateTime? _ShipDate; - private StatusEnum? _Status; - private bool? _Complete; - - internal OrderBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - _Complete = false; - } - - /// <summary> - /// Sets value for Order.Id property. - /// </summary> - /// <param name="value">Id</param> - public OrderBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Order.PetId property. - /// </summary> - /// <param name="value">PetId</param> - public OrderBuilder PetId(long? value) - { - _PetId = value; - return this; - } - - /// <summary> - /// Sets value for Order.Quantity property. - /// </summary> - /// <param name="value">Quantity</param> - public OrderBuilder Quantity(int? value) - { - _Quantity = value; - return this; - } - - /// <summary> - /// Sets value for Order.ShipDate property. - /// </summary> - /// <param name="value">ShipDate</param> - public OrderBuilder ShipDate(ZonedDateTime? value) - { - _ShipDate = value; - return this; - } - - /// <summary> - /// Sets value for Order.Status property. - /// </summary> - /// <param name="value">Order Status</param> - public OrderBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - /// <summary> - /// Sets value for Order.Complete property. - /// </summary> - /// <param name="value">Complete</param> - public OrderBuilder Complete(bool? value) - { - _Complete = value; - return this; - } - - - /// <summary> - /// Builds instance of Order. - /// </summary> - /// <returns>Order</returns> - public Order Build() - { - Validate(); - return new Order( - Id: _Id, - PetId: _PetId, - Quantity: _Quantity, - ShipDate: _ShipDate, - Status: _Status, - Complete: _Complete - ); - } - - private void Validate() - { - } - } - - - public enum StatusEnum { Placed, Approved, Delivered }; - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Pet.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Pet.cs deleted file mode 100644 index f945a0fdd78..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Pet.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// A pet for sale in the pet store - /// </summary> - public sealed class Pet: IEquatable<Pet> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Category - /// </summary> - public Category Category { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - /// <summary> - /// PhotoUrls - /// </summary> - public List<string> PhotoUrls { get; private set; } - - /// <summary> - /// Tags - /// </summary> - public List<Tag> Tags { get; private set; } - - /// <summary> - /// pet status in the store - /// </summary> - public StatusEnum? Status { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Pet.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Pet() - { - } - - private Pet(long? Id, Category Category, string Name, List<string> PhotoUrls, List<Tag> Tags, StatusEnum? Status) - { - - this.Id = Id; - - this.Category = Category; - - this.Name = Name; - - this.PhotoUrls = PhotoUrls; - - this.Tags = Tags; - - this.Status = Status; - - } - - /// <summary> - /// Returns builder of Pet. - /// </summary> - /// <returns>PetBuilder</returns> - public static PetBuilder Builder() - { - return new PetBuilder(); - } - - /// <summary> - /// Returns PetBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>PetBuilder</returns> - public PetBuilder With() - { - return Builder() - .Id(Id) - .Category(Category) - .Name(Name) - .PhotoUrls(PhotoUrls) - .Tags(Tags) - .Status(Status); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Pet other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Pet left, Pet right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Pet left, Pet right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Pet. - /// </summary> - public sealed class PetBuilder - { - private long? _Id; - private Category _Category; - private string _Name; - private List<string> _PhotoUrls; - private List<Tag> _Tags; - private StatusEnum? _Status; - - internal PetBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Pet.Id property. - /// </summary> - /// <param name="value">Id</param> - public PetBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Category property. - /// </summary> - /// <param name="value">Category</param> - public PetBuilder Category(Category value) - { - _Category = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Name property. - /// </summary> - /// <param name="value">Name</param> - public PetBuilder Name(string value) - { - _Name = value; - return this; - } - - /// <summary> - /// Sets value for Pet.PhotoUrls property. - /// </summary> - /// <param name="value">PhotoUrls</param> - public PetBuilder PhotoUrls(List<string> value) - { - _PhotoUrls = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Tags property. - /// </summary> - /// <param name="value">Tags</param> - public PetBuilder Tags(List<Tag> value) - { - _Tags = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Status property. - /// </summary> - /// <param name="value">pet status in the store</param> - public PetBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - - /// <summary> - /// Builds instance of Pet. - /// </summary> - /// <returns>Pet</returns> - public Pet Build() - { - Validate(); - return new Pet( - Id: _Id, - Category: _Category, - Name: _Name, - PhotoUrls: _PhotoUrls, - Tags: _Tags, - Status: _Status - ); - } - - private void Validate() - { - if (_Name == null) - { - throw new ArgumentException("Name is a required property for Pet and cannot be null"); - } - if (_PhotoUrls == null) - { - throw new ArgumentException("PhotoUrls is a required property for Pet and cannot be null"); - } - } - } - - - public enum StatusEnum { Available, Pending, Sold }; - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Tag.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Tag.cs deleted file mode 100644 index 02d1e40f1ec..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/Tag.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// A tag for a pet - /// </summary> - public sealed class Tag: IEquatable<Tag> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Tag.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Tag() - { - } - - private Tag(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Tag. - /// </summary> - /// <returns>TagBuilder</returns> - public static TagBuilder Builder() - { - return new TagBuilder(); - } - - /// <summary> - /// Returns TagBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>TagBuilder</returns> - public TagBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Tag other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Tag left, Tag right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Tag left, Tag right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Tag. - /// </summary> - public sealed class TagBuilder - { - private long? _Id; - private string _Name; - - internal TagBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Tag.Id property. - /// </summary> - /// <param name="value">Id</param> - public TagBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Tag.Name property. - /// </summary> - /// <param name="value">Name</param> - public TagBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Tag. - /// </summary> - /// <returns>Tag</returns> - public Tag Build() - { - Validate(); - return new Tag( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/User.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/User.cs deleted file mode 100644 index 99f401750df..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Models/User.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace IO.Swagger.v2.Models -{ - /// <summary> - /// A User who is purchasing from the pet store - /// </summary> - public sealed class User: IEquatable<User> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Username - /// </summary> - public string Username { get; private set; } - - /// <summary> - /// FirstName - /// </summary> - public string FirstName { get; private set; } - - /// <summary> - /// LastName - /// </summary> - public string LastName { get; private set; } - - /// <summary> - /// Email - /// </summary> - public string Email { get; private set; } - - /// <summary> - /// Password - /// </summary> - public string Password { get; private set; } - - /// <summary> - /// Phone - /// </summary> - public string Phone { get; private set; } - - /// <summary> - /// User Status - /// </summary> - public int? UserStatus { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use User.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public User() - { - } - - private User(long? Id, string Username, string FirstName, string LastName, string Email, string Password, string Phone, int? UserStatus) - { - - this.Id = Id; - - this.Username = Username; - - this.FirstName = FirstName; - - this.LastName = LastName; - - this.Email = Email; - - this.Password = Password; - - this.Phone = Phone; - - this.UserStatus = UserStatus; - - } - - /// <summary> - /// Returns builder of User. - /// </summary> - /// <returns>UserBuilder</returns> - public static UserBuilder Builder() - { - return new UserBuilder(); - } - - /// <summary> - /// Returns UserBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>UserBuilder</returns> - public UserBuilder With() - { - return Builder() - .Id(Id) - .Username(Username) - .FirstName(FirstName) - .LastName(LastName) - .Email(Email) - .Password(Password) - .Phone(Phone) - .UserStatus(UserStatus); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(User other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (User left, User right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (User left, User right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of User. - /// </summary> - public sealed class UserBuilder - { - private long? _Id; - private string _Username; - private string _FirstName; - private string _LastName; - private string _Email; - private string _Password; - private string _Phone; - private int? _UserStatus; - - internal UserBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for User.Id property. - /// </summary> - /// <param name="value">Id</param> - public UserBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for User.Username property. - /// </summary> - /// <param name="value">Username</param> - public UserBuilder Username(string value) - { - _Username = value; - return this; - } - - /// <summary> - /// Sets value for User.FirstName property. - /// </summary> - /// <param name="value">FirstName</param> - public UserBuilder FirstName(string value) - { - _FirstName = value; - return this; - } - - /// <summary> - /// Sets value for User.LastName property. - /// </summary> - /// <param name="value">LastName</param> - public UserBuilder LastName(string value) - { - _LastName = value; - return this; - } - - /// <summary> - /// Sets value for User.Email property. - /// </summary> - /// <param name="value">Email</param> - public UserBuilder Email(string value) - { - _Email = value; - return this; - } - - /// <summary> - /// Sets value for User.Password property. - /// </summary> - /// <param name="value">Password</param> - public UserBuilder Password(string value) - { - _Password = value; - return this; - } - - /// <summary> - /// Sets value for User.Phone property. - /// </summary> - /// <param name="value">Phone</param> - public UserBuilder Phone(string value) - { - _Phone = value; - return this; - } - - /// <summary> - /// Sets value for User.UserStatus property. - /// </summary> - /// <param name="value">User Status</param> - public UserBuilder UserStatus(int? value) - { - _UserStatus = value; - return this; - } - - - /// <summary> - /// Builds instance of User. - /// </summary> - /// <returns>User</returns> - public User Build() - { - Validate(); - return new User( - Id: _Id, - Username: _Username, - FirstName: _FirstName, - LastName: _LastName, - Email: _Email, - Password: _Password, - Phone: _Phone, - UserStatus: _UserStatus - ); - } - - private void Validate() - { - } - } - - - } -} \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/PetModule.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/PetModule.cs deleted file mode 100644 index 6b3e8cc1db8..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/PetModule.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using IO.Swagger.v2.Models; -using IO.Swagger.v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace IO.Swagger.v2.Modules -{ - /// <summary> - /// Status values that need to be considered for filter - /// </summary> - public enum FindPetsByStatusStatusEnum - { - available = 1, - pending = 2, - sold = 3 - }; - - - /// <summary> - /// Module processing requests of Pet domain. - /// </summary> - public sealed class PetModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public PetModule(PetService service) : base("/v2") - { - Post["/pet", true] = async (parameters, ct) => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'AddPet'"); - - await service.AddPet(Context, body); - return new Response { ContentType = "application/xml"}; - }; - - Delete["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var apiKey = Parameters.ValueOf<string>(parameters, Context.Request, "apiKey", ParameterType.Header); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'DeletePet'"); - - await service.DeletePet(Context, petId, apiKey); - return new Response { ContentType = "application/xml"}; - }; - - Get["/pet/findByStatus", true] = async (parameters, ct) => - { - var status = Parameters.ValueOf<FindPetsByStatusStatusEnum?>(parameters, Context.Request, "status", ParameterType.Query); - Preconditions.IsNotNull(status, "Required parameter: 'status' is missing at 'FindPetsByStatus'"); - - return await service.FindPetsByStatus(Context, status).ToArray(); - }; - - Get["/pet/findByTags", true] = async (parameters, ct) => - { - var tags = Parameters.ValueOf<List<string>>(parameters, Context.Request, "tags", ParameterType.Query); - Preconditions.IsNotNull(tags, "Required parameter: 'tags' is missing at 'FindPetsByTags'"); - - return await service.FindPetsByTags(Context, tags).ToArray(); - }; - - Get["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'GetPetById'"); - - return await service.GetPetById(Context, petId); - }; - - Put["/pet", true] = async (parameters, ct) => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdatePet'"); - - await service.UpdatePet(Context, body); - return new Response { ContentType = "application/xml"}; - }; - - Post["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var name = Parameters.ValueOf<string>(parameters, Context.Request, "name", ParameterType.Undefined); - var status = Parameters.ValueOf<string>(parameters, Context.Request, "status", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UpdatePetWithForm'"); - - await service.UpdatePetWithForm(Context, petId, name, status); - return new Response { ContentType = "application/xml"}; - }; - - Post["/pet/{petId}/uploadImage", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var additionalMetadata = Parameters.ValueOf<string>(parameters, Context.Request, "additionalMetadata", ParameterType.Undefined); - var file = Parameters.ValueOf<System.IO.Stream>(parameters, Context.Request, "file", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UploadFile'"); - - return await service.UploadFile(Context, petId, additionalMetadata, file); - }; - } - } - - /// <summary> - /// Service handling Pet requests. - /// </summary> - public interface PetService - { - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - Task AddPet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional)</param> - /// <returns></returns> - Task DeletePet(NancyContext context, long? petId, string apiKey); - - /// <summary> - /// Multiple status values can be provided with comma separated strings - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="status">Status values that need to be considered for filter</param> - /// <returns>List<Pet></returns> - Task<List<Pet>> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status); - - /// <summary> - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="tags">Tags to filter by</param> - /// <returns>List<Pet></returns> - Task<List<Pet>> FindPetsByTags(NancyContext context, List<string> tags); - - /// <summary> - /// Returns a single pet - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to return</param> - /// <returns>Pet</returns> - Task<Pet> GetPetById(NancyContext context, long? petId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - Task UpdatePet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet that needs to be updated</param> - /// <param name="name">Updated name of the pet (optional)</param> - /// <param name="status">Updated status of the pet (optional)</param> - /// <returns></returns> - Task UpdatePetWithForm(NancyContext context, long? petId, string name, string status); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to update</param> - /// <param name="additionalMetadata">Additional data to pass to server (optional)</param> - /// <param name="file">file to upload (optional)</param> - /// <returns>ApiResponse</returns> - Task<ApiResponse> UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file); - } - - /// <summary> - /// Abstraction of PetService. - /// </summary> - public abstract class AbstractPetService: PetService - { - public virtual Task AddPet(NancyContext context, Pet body) - { - return AddPet(body); - } - - public virtual Task DeletePet(NancyContext context, long? petId, string apiKey) - { - return DeletePet(petId, apiKey); - } - - public virtual Task<List<Pet>> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status) - { - return FindPetsByStatus(status); - } - - public virtual Task<List<Pet>> FindPetsByTags(NancyContext context, List<string> tags) - { - return FindPetsByTags(tags); - } - - public virtual Task<Pet> GetPetById(NancyContext context, long? petId) - { - return GetPetById(petId); - } - - public virtual Task UpdatePet(NancyContext context, Pet body) - { - return UpdatePet(body); - } - - public virtual Task UpdatePetWithForm(NancyContext context, long? petId, string name, string status) - { - return UpdatePetWithForm(petId, name, status); - } - - public virtual Task<ApiResponse> UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file) - { - return UploadFile(petId, additionalMetadata, file); - } - - protected abstract Task AddPet(Pet body); - - protected abstract Task DeletePet(long? petId, string apiKey); - - protected abstract Task<List<Pet>> FindPetsByStatus(FindPetsByStatusStatusEnum? status); - - protected abstract Task<List<Pet>> FindPetsByTags(List<string> tags); - - protected abstract Task<Pet> GetPetById(long? petId); - - protected abstract Task UpdatePet(Pet body); - - protected abstract Task UpdatePetWithForm(long? petId, string name, string status); - - protected abstract Task<ApiResponse> UploadFile(long? petId, string additionalMetadata, System.IO.Stream file); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/StoreModule.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/StoreModule.cs deleted file mode 100644 index 30c46234256..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/StoreModule.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using IO.Swagger.v2.Models; -using IO.Swagger.v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace IO.Swagger.v2.Modules -{ - - /// <summary> - /// Module processing requests of Store domain. - /// </summary> - public sealed class StoreModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public StoreModule(StoreService service) : base("/v2") - { - Delete["/store/order/{orderId}", true] = async (parameters, ct) => - { - var orderId = Parameters.ValueOf<string>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'DeleteOrder'"); - - await service.DeleteOrder(Context, orderId); - return new Response { ContentType = "application/xml"}; - }; - - Get["/store/inventory", true] = async (parameters, ct) => - { - - return await service.GetInventory(Context); - }; - - Get["/store/order/{orderId}", true] = async (parameters, ct) => - { - var orderId = Parameters.ValueOf<long?>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'GetOrderById'"); - - return await service.GetOrderById(Context, orderId); - }; - - Post["/store/order", true] = async (parameters, ct) => - { - var body = this.Bind<Order>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'PlaceOrder'"); - - return await service.PlaceOrder(Context, body); - }; - } - } - - /// <summary> - /// Service handling Store requests. - /// </summary> - public interface StoreService - { - /// <summary> - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of the order that needs to be deleted</param> - /// <returns></returns> - Task DeleteOrder(NancyContext context, string orderId); - - /// <summary> - /// Returns a map of status codes to quantities - /// </summary> - /// <param name="context">Context of request</param> - /// <returns>Dictionary<string, int?></returns> - Task<Dictionary<string, int?>> GetInventory(NancyContext context); - - /// <summary> - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of pet that needs to be fetched</param> - /// <returns>Order</returns> - Task<Order> GetOrderById(NancyContext context, long? orderId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">order placed for purchasing the pet</param> - /// <returns>Order</returns> - Task<Order> PlaceOrder(NancyContext context, Order body); - } - - /// <summary> - /// Abstraction of StoreService. - /// </summary> - public abstract class AbstractStoreService: StoreService - { - public virtual Task DeleteOrder(NancyContext context, string orderId) - { - return DeleteOrder(orderId); - } - - public virtual Task<Dictionary<string, int?>> GetInventory(NancyContext context) - { - return GetInventory(); - } - - public virtual Task<Order> GetOrderById(NancyContext context, long? orderId) - { - return GetOrderById(orderId); - } - - public virtual Task<Order> PlaceOrder(NancyContext context, Order body) - { - return PlaceOrder(body); - } - - protected abstract Task DeleteOrder(string orderId); - - protected abstract Task<Dictionary<string, int?>> GetInventory(); - - protected abstract Task<Order> GetOrderById(long? orderId); - - protected abstract Task<Order> PlaceOrder(Order body); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/UserModule.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/UserModule.cs deleted file mode 100644 index 4faf9e38dbd..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Modules/UserModule.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using IO.Swagger.v2.Models; -using IO.Swagger.v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace IO.Swagger.v2.Modules -{ - - /// <summary> - /// Module processing requests of User domain. - /// </summary> - public sealed class UserModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public UserModule(UserService service) : base("/v2") - { - Post["/user", true] = async (parameters, ct) => - { - var body = this.Bind<User>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUser'"); - - await service.CreateUser(Context, body); - return new Response { ContentType = "application/xml"}; - }; - - Post["/user/createWithArray", true] = async (parameters, ct) => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithArrayInput'"); - - await service.CreateUsersWithArrayInput(Context, body); - return new Response { ContentType = "application/xml"}; - }; - - Post["/user/createWithList", true] = async (parameters, ct) => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithListInput'"); - - await service.CreateUsersWithListInput(Context, body); - return new Response { ContentType = "application/xml"}; - }; - - Delete["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'DeleteUser'"); - - await service.DeleteUser(Context, username); - return new Response { ContentType = "application/xml"}; - }; - - Get["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'GetUserByName'"); - - return await service.GetUserByName(Context, username); - }; - - Get["/user/login", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Query); - var password = Parameters.ValueOf<string>(parameters, Context.Request, "password", ParameterType.Query); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'LoginUser'"); - - Preconditions.IsNotNull(password, "Required parameter: 'password' is missing at 'LoginUser'"); - - return await service.LoginUser(Context, username, password); - }; - - Get["/user/logout", true] = async (parameters, ct) => - { - - await service.LogoutUser(Context); - return new Response { ContentType = "application/xml"}; - }; - - Put["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - var body = this.Bind<User>(); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'UpdateUser'"); - - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdateUser'"); - - await service.UpdateUser(Context, username, body); - return new Response { ContentType = "application/xml"}; - }; - } - } - - /// <summary> - /// Service handling User requests. - /// </summary> - public interface UserService - { - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Created user object</param> - /// <returns></returns> - Task CreateUser(NancyContext context, User body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - Task CreateUsersWithArrayInput(NancyContext context, List<User> body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - Task CreateUsersWithListInput(NancyContext context, List<User> body); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be deleted</param> - /// <returns></returns> - Task DeleteUser(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be fetched. Use user1 for testing. </param> - /// <returns>User</returns> - Task<User> GetUserByName(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The user name for login</param> - /// <param name="password">The password for login in clear text</param> - /// <returns>string</returns> - Task<string> LoginUser(NancyContext context, string username, string password); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <returns></returns> - Task LogoutUser(NancyContext context); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">name that need to be deleted</param> - /// <param name="body">Updated user object</param> - /// <returns></returns> - Task UpdateUser(NancyContext context, string username, User body); - } - - /// <summary> - /// Abstraction of UserService. - /// </summary> - public abstract class AbstractUserService: UserService - { - public virtual Task CreateUser(NancyContext context, User body) - { - return CreateUser(body); - } - - public virtual Task CreateUsersWithArrayInput(NancyContext context, List<User> body) - { - return CreateUsersWithArrayInput(body); - } - - public virtual Task CreateUsersWithListInput(NancyContext context, List<User> body) - { - return CreateUsersWithListInput(body); - } - - public virtual Task DeleteUser(NancyContext context, string username) - { - return DeleteUser(username); - } - - public virtual Task<User> GetUserByName(NancyContext context, string username) - { - return GetUserByName(username); - } - - public virtual Task<string> LoginUser(NancyContext context, string username, string password) - { - return LoginUser(username, password); - } - - public virtual Task LogoutUser(NancyContext context) - { - return LogoutUser(); - } - - public virtual Task UpdateUser(NancyContext context, string username, User body) - { - return UpdateUser(username, body); - } - - protected abstract Task CreateUser(User body); - - protected abstract Task CreateUsersWithArrayInput(List<User> body); - - protected abstract Task CreateUsersWithListInput(List<User> body); - - protected abstract Task DeleteUser(string username); - - protected abstract Task<User> GetUserByName(string username); - - protected abstract Task<string> LoginUser(string username, string password); - - protected abstract Task LogoutUser(); - - protected abstract Task UpdateUser(string username, User body); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/LocalDateConverter.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/LocalDateConverter.cs deleted file mode 100644 index d801e962c6a..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/LocalDateConverter.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Nancy.Bootstrapper; -using Nancy.Json; -using NodaTime; -using NodaTime.Text; -using System; -using System.Collections.Generic; - -namespace IO.Swagger.v2.Utils -{ - /// <summary> - /// (De)serializes a <see cref="NodaTime.LocalDate"/> to a string using - /// the <a href="https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14">RFC3339</a> - /// <code>full-date</code> format. - /// </summary> - public class LocalDateConverter : JavaScriptPrimitiveConverter, IApplicationStartup - { - public override IEnumerable<Type> SupportedTypes - { - get - { - yield return typeof(LocalDate); - yield return typeof(LocalDate?); - } - } - - public void Initialize(IPipelines pipelines) - { - JsonSettings.PrimitiveConverters.Add(new LocalDateConverter()); - } - - - public override object Serialize(object obj, JavaScriptSerializer serializer) - { - if (obj is LocalDate) - { - LocalDate localDate = (LocalDate)obj; - return LocalDatePattern.IsoPattern.Format(localDate); - } - return null; - } - - public override object Deserialize(object primitiveValue, Type type, JavaScriptSerializer serializer) - { - if ((type == typeof(LocalDate) || type == typeof(LocalDate?)) && primitiveValue is string) - { - try - { - return LocalDatePattern.IsoPattern.Parse(primitiveValue as string).GetValueOrThrow(); - } - catch { } - } - return null; - } - } -} diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/Parameters.cs b/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/Parameters.cs deleted file mode 100644 index d2198945763..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/Utils/Parameters.cs +++ /dev/null @@ -1,450 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Nancy; -using NodaTime; -using NodaTime.Text; -using Sharpility.Base; -using Sharpility.Extensions; -using Sharpility.Util; - -namespace IO.Swagger.v2.Utils -{ - internal static class Parameters - { - private static readonly IDictionary<Type, Func<Parameter, object>> Parsers = CreateParsers(); - - internal static TValue ValueOf<TValue>(dynamic parameters, Request request, string name, ParameterType parameterType) - { - var valueType = typeof(TValue); - var valueUnderlyingType = Nullable.GetUnderlyingType(valueType); - var isNullable = default(TValue) == null; - string value = RawValueOf(parameters, request, name, parameterType); - Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name)); - if (value == null && isNullable) - { - return default(TValue); - } - if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum)) - { - return EnumValueOf<TValue>(name, value); - } - return ValueOf<TValue>(parameters, name, value, valueType, request, parameterType); - } - - private static string RawValueOf(dynamic parameters, Request request, string name, ParameterType parameterType) - { - try - { - switch (parameterType) - { - case ParameterType.Query: - string querValue = request.Query[name]; - return querValue; - case ParameterType.Path: - string pathValue = parameters[name]; - return pathValue; - case ParameterType.Header: - var headerValue = request.Headers[name]; - return headerValue != null ? string.Join(",", headerValue) : null; - } - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not obtain value of '{0}' parameter", name), e); - } - throw new InvalidOperationException(string.Format("Parameter with type: {0} is not supported", parameterType)); - } - - private static TValue EnumValueOf<TValue>(string name, string value) - { - var valueType = typeof(TValue); - var enumType = valueType.IsEnum ? valueType : Nullable.GetUnderlyingType(valueType); - Preconditions.IsNotNull(enumType, () => new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' to enum. Type {1} is not enum", name, valueType))); - var values = Enum.GetValues(enumType); - foreach (var entry in values) - { - if (entry.ToString().EqualsIgnoreCases(value) - || ((int)entry).ToString().EqualsIgnoreCases(value)) - { - return (TValue)entry; - } - } - throw new ArgumentException(string.Format("Parameter: '{0}' value: '{1}' is not supported. Expected one of: {2}", - name, value, Strings.ToString(values))); - } - - private static TValue ValueOf<TValue>(dynamic parameters, string name, string value, Type valueType, Request request, ParameterType parameterType) - { - var parser = Parsers.GetIfPresent(valueType); - if (parser != null) - { - return ParseValueUsing<TValue>(name, value, valueType, parser); - } - if (parameterType == ParameterType.Path) - { - return DynamicValueOf<TValue>(parameters, name); - } - if (parameterType == ParameterType.Query) - { - return DynamicValueOf<TValue>(request.Query, name); - } - throw new InvalidOperationException(string.Format("Could not get value for {0} with type {1}", name, valueType)); - } - - private static TValue ParseValueUsing<TValue>(string name, string value, Type valueType, Func<Parameter, object> parser) - { - var result = parser(Parameter.Of(name, value)); - try - { - return (TValue)result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' with value: '{1}'. " + - "Received: '{2}', expected: '{3}'.", - name, value, result.GetType(), valueType)); - } - } - - private static TValue DynamicValueOf<TValue>(dynamic parameters, string name) - { - string value = parameters[name]; - try - { - TValue result = parameters[name]; - return result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException(Strings.Format("Parameter: '{0}' value: '{1}' could not be parsed. " + - "Expected type: '{2}' is not supported", - name, value, typeof(TValue))); - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not get '{0}' value of '{1}' type dynamicly", - name, typeof(TValue)), e); - } - } - - private static IDictionary<Type, Func<Parameter, object>> CreateParsers() - { - var parsers = ImmutableDictionary.CreateBuilder<Type, Func<Parameter, object>>(); - parsers.Put(typeof(string), value => value.Value); - parsers.Put(typeof(bool), SafeParse(bool.Parse)); - parsers.Put(typeof(bool?), SafeParse(bool.Parse)); - parsers.Put(typeof(byte), SafeParse(byte.Parse)); - parsers.Put(typeof(sbyte?), SafeParse(sbyte.Parse)); - parsers.Put(typeof(short), SafeParse(short.Parse)); - parsers.Put(typeof(short?), SafeParse(short.Parse)); - parsers.Put(typeof(ushort), SafeParse(ushort.Parse)); - parsers.Put(typeof(ushort?), SafeParse(ushort.Parse)); - parsers.Put(typeof(int), SafeParse(int.Parse)); - parsers.Put(typeof(int?), SafeParse(int.Parse)); - parsers.Put(typeof(uint), SafeParse(uint.Parse)); - parsers.Put(typeof(uint?), SafeParse(uint.Parse)); - parsers.Put(typeof(long), SafeParse(long.Parse)); - parsers.Put(typeof(long?), SafeParse(long.Parse)); - parsers.Put(typeof(ulong), SafeParse(ulong.Parse)); - parsers.Put(typeof(ulong?), SafeParse(ulong.Parse)); - parsers.Put(typeof(float), SafeParse(float.Parse)); - parsers.Put(typeof(float?), SafeParse(float.Parse)); - parsers.Put(typeof(double), SafeParse(double.Parse)); - parsers.Put(typeof(double?), SafeParse(double.Parse)); - parsers.Put(typeof(decimal), SafeParse(decimal.Parse)); - parsers.Put(typeof(decimal?), SafeParse(decimal.Parse)); - parsers.Put(typeof(DateTime), SafeParse(DateTime.Parse)); - parsers.Put(typeof(DateTime?), SafeParse(DateTime.Parse)); - parsers.Put(typeof(TimeSpan), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(TimeSpan?), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(ZonedDateTime), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(ZonedDateTime?), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(LocalDate), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalDate?), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalTime), SafeParse(ParseLocalTime)); - parsers.Put(typeof(LocalTime?), SafeParse(ParseLocalTime)); - - parsers.Put(typeof(IEnumerable<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(ICollection<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(IList<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(List<string>), ListParse(value => value)); - parsers.Put(typeof(ISet<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(HashSet<string>), SetParse(value => value)); - - parsers.Put(typeof(IEnumerable<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(ICollection<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(IList<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(List<bool?>), NullableListParse(bool.Parse)); - parsers.Put(typeof(ISet<bool?>), NullableImmutableSetParse(bool.Parse)); - parsers.Put(typeof(HashSet<bool?>), NullableSetParse(bool.Parse)); - - parsers.Put(typeof(IEnumerable<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(ICollection<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(IList<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(List<byte>), ListParse(byte.Parse)); - parsers.Put(typeof(ISet<byte>), ImmutableSetParse(byte.Parse)); - parsers.Put(typeof(HashSet<byte>), SetParse(byte.Parse)); - - parsers.Put(typeof(IEnumerable<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(ICollection<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(IList<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(List<sbyte>), ListParse(sbyte.Parse)); - parsers.Put(typeof(ISet<sbyte>), ImmutableSetParse(sbyte.Parse)); - parsers.Put(typeof(HashSet<sbyte>), SetParse(sbyte.Parse)); - - parsers.Put(typeof(IEnumerable<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(ICollection<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(IList<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(List<short>), ListParse(short.Parse)); - parsers.Put(typeof(ISet<short>), ImmutableSetParse(short.Parse)); - parsers.Put(typeof(HashSet<short>), SetParse(short.Parse)); - - parsers.Put(typeof(IEnumerable<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(ICollection<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(IList<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(List<ushort>), ListParse(ushort.Parse)); - parsers.Put(typeof(ISet<ushort>), ImmutableSetParse(ushort.Parse)); - parsers.Put(typeof(HashSet<ushort>), SetParse(ushort.Parse)); - - parsers.Put(typeof(IEnumerable<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(ICollection<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(IList<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(List<int?>), NullableListParse(int.Parse)); - parsers.Put(typeof(ISet<int?>), NullableImmutableSetParse(int.Parse)); - parsers.Put(typeof(HashSet<int?>), NullableSetParse(int.Parse)); - - parsers.Put(typeof(IEnumerable<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(ICollection<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(IList<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(List<uint>), ListParse(uint.Parse)); - parsers.Put(typeof(ISet<uint>), ImmutableSetParse(uint.Parse)); - parsers.Put(typeof(HashSet<uint>), SetParse(uint.Parse)); - - parsers.Put(typeof(IEnumerable<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(ICollection<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(IList<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(List<long?>), NullableListParse(long.Parse)); - parsers.Put(typeof(ISet<long?>), NullableImmutableSetParse(long.Parse)); - parsers.Put(typeof(HashSet<long?>), NullableSetParse(long.Parse)); - - parsers.Put(typeof(IEnumerable<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(ICollection<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(IList<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(List<ulong>), ListParse(ulong.Parse)); - parsers.Put(typeof(ISet<ulong>), ImmutableSetParse(ulong.Parse)); - parsers.Put(typeof(HashSet<ulong>), SetParse(ulong.Parse)); - - parsers.Put(typeof(IEnumerable<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(ICollection<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(IList<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(List<float?>), NullableListParse(float.Parse)); - parsers.Put(typeof(ISet<float?>), NullableImmutableSetParse(float.Parse)); - parsers.Put(typeof(HashSet<float?>), NullableSetParse(float.Parse)); - - parsers.Put(typeof(IEnumerable<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(ICollection<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(IList<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(List<double?>), NullableListParse(double.Parse)); - parsers.Put(typeof(ISet<double?>), NullableImmutableSetParse(double.Parse)); - parsers.Put(typeof(HashSet<double?>), NullableSetParse(double.Parse)); - - parsers.Put(typeof(IEnumerable<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(ICollection<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(IList<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(List<decimal?>), NullableListParse(decimal.Parse)); - parsers.Put(typeof(ISet<decimal?>), NullableImmutableSetParse(decimal.Parse)); - parsers.Put(typeof(HashSet<decimal?>), NullableSetParse(decimal.Parse)); - - parsers.Put(typeof(IEnumerable<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(ICollection<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(IList<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(List<DateTime?>), NullableListParse(DateTime.Parse)); - parsers.Put(typeof(ISet<DateTime?>), NullableImmutableSetParse(DateTime.Parse)); - parsers.Put(typeof(HashSet<DateTime?>), NullableSetParse(DateTime.Parse)); - - parsers.Put(typeof(IEnumerable<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(ICollection<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(IList<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(List<TimeSpan>), ListParse(TimeSpan.Parse)); - parsers.Put(typeof(ISet<TimeSpan>), ImmutableSetParse(TimeSpan.Parse)); - parsers.Put(typeof(HashSet<TimeSpan>), SetParse(TimeSpan.Parse)); - - return parsers.ToImmutableDictionary(); - } - - private static Func<Parameter, object> SafeParse<T>(Func<string, T> parse) - { - return parameter => - { - try - { - return parse(parameter.Value); - } - catch (OverflowException) - { - throw ParameterOutOfRange(parameter, typeof(T)); - } - catch (FormatException) - { - throw InvalidParameterFormat(parameter, typeof(T)); - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse parameter: '{0}' with value: '{1}' to {2}", - parameter.Name, parameter.Value, typeof(T)), e); - } - }; - } - - private static Func<Parameter, object> NullableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new List<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToList(); - }; - } - - private static Func<Parameter, object> NullableImmutableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Lists.EmptyList<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableList(); - }; - } - - private static Func<Parameter, object> NullableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return SetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> SetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new HashSet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToSet(); - }; - } - - private static Func<Parameter, object> NullableImmutableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableSetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableSetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Sets.EmptySet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableHashSet(); - }; - } - - private static ZonedDateTime ParseZonedDateTime(string value) - { - var dateTime = DateTime.Parse(value); - return new ZonedDateTime(Instant.FromDateTimeUtc(dateTime.ToUniversalTime()), DateTimeZone.Utc); - } - - private static LocalDate ParseLocalDate(string value) - { - return LocalDatePattern.IsoPattern.Parse(value).Value; - } - - private static LocalTime ParseLocalTime(string value) - { - return LocalTimePattern.ExtendedIsoPattern.Parse(value).Value; - } - - private static ArgumentException ParameterOutOfRange(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query: '{0}' value: '{1}' is out of range for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static ArgumentException InvalidParameterFormat(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query '{0}' value: '{1}' format is invalid for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static IEnumerable<T> ParseCollection<T>(string value, Func<string, T> itemParser) - { - var results = value.Split(new[] { ',' }, StringSplitOptions.None) - .Where(it => it != null) - .Select(it => it.Trim()) - .Select(itemParser); - return results; - } - - public static T? ToNullable<T>(this string s, Func<string, T> itemParser) where T : struct - { - T? result = new T?(); - try - { - if (!string.IsNullOrEmpty(s) && s.Trim().Length > 0) - { - result = itemParser(s); - } - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse value: '{0}' to nullable: '{1}'", s, typeof(T).ToString()), e); - } - return result; - } - - private class Parameter - { - internal string Name { get; private set; } - internal string Value { get; private set; } - - private Parameter(string name, string value) - { - Name = name; - Value = value; - } - - internal static Parameter Of(string name, string value) - { - return new Parameter(name, value); - } - } - } - - internal enum ParameterType - { - Undefined, - Query, - Path, - Header - } -} diff --git a/samples/server/petstore/nancyfx-async/src/IO.Swagger/packages.config b/samples/server/petstore/nancyfx-async/src/IO.Swagger/packages.config deleted file mode 100644 index e3401566e5d..00000000000 --- a/samples/server/petstore/nancyfx-async/src/IO.Swagger/packages.config +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="Nancy" version="1.4.3" targetFramework="net45" /> - <package id="NodaTime" version="1.3.1" targetFramework="net45" /> - <package id="Sharpility" version="1.2.2" targetFramework="net45" /> - <package id="System.Collections.Immutable" version="1.1.37" targetFramework="net45" /> -</packages> \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/ApiResponse.cs deleted file mode 100644 index 2c35c0c5fd9..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/ApiResponse.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// Describes the result of uploading an image resource - /// </summary> - public sealed class ApiResponse: IEquatable<ApiResponse> - { - /// <summary> - /// Code - /// </summary> - public int? Code { get; private set; } - - /// <summary> - /// Type - /// </summary> - public string Type { get; private set; } - - /// <summary> - /// Message - /// </summary> - public string Message { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use ApiResponse.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public ApiResponse() - { - } - - private ApiResponse(int? Code, string Type, string Message) - { - - this.Code = Code; - - this.Type = Type; - - this.Message = Message; - - } - - /// <summary> - /// Returns builder of ApiResponse. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public static ApiResponseBuilder Builder() - { - return new ApiResponseBuilder(); - } - - /// <summary> - /// Returns ApiResponseBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public ApiResponseBuilder With() - { - return Builder() - .Code(Code) - .Type(Type) - .Message(Message); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(ApiResponse other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (ApiResponse left, ApiResponse right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (ApiResponse left, ApiResponse right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of ApiResponse. - /// </summary> - public sealed class ApiResponseBuilder - { - private int? _Code; - private string _Type; - private string _Message; - - internal ApiResponseBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for ApiResponse.Code property. - /// </summary> - /// <param name="value">Code</param> - public ApiResponseBuilder Code(int? value) - { - _Code = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Type property. - /// </summary> - /// <param name="value">Type</param> - public ApiResponseBuilder Type(string value) - { - _Type = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Message property. - /// </summary> - /// <param name="value">Message</param> - public ApiResponseBuilder Message(string value) - { - _Message = value; - return this; - } - - - /// <summary> - /// Builds instance of ApiResponse. - /// </summary> - /// <returns>ApiResponse</returns> - public ApiResponse Build() - { - Validate(); - return new ApiResponse( - Code: _Code, - Type: _Type, - Message: _Message - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Category.cs deleted file mode 100644 index 3cadeec39fe..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Category.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A category for a pet - /// </summary> - public sealed class Category: IEquatable<Category> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Category.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Category() - { - } - - private Category(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Category. - /// </summary> - /// <returns>CategoryBuilder</returns> - public static CategoryBuilder Builder() - { - return new CategoryBuilder(); - } - - /// <summary> - /// Returns CategoryBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>CategoryBuilder</returns> - public CategoryBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Category other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Category left, Category right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Category left, Category right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Category. - /// </summary> - public sealed class CategoryBuilder - { - private long? _Id; - private string _Name; - - internal CategoryBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Category.Id property. - /// </summary> - /// <param name="value">Id</param> - public CategoryBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Category.Name property. - /// </summary> - /// <param name="value">Name</param> - public CategoryBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Category. - /// </summary> - /// <returns>Category</returns> - public Category Build() - { - Validate(); - return new Category( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Order.cs deleted file mode 100644 index 3ef8e9133c7..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Order.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// An order for a pets from the pet store - /// </summary> - public sealed class Order: IEquatable<Order> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// PetId - /// </summary> - public long? PetId { get; private set; } - - /// <summary> - /// Quantity - /// </summary> - public int? Quantity { get; private set; } - - /// <summary> - /// ShipDate - /// </summary> - public DateTime? ShipDate { get; private set; } - - /// <summary> - /// Order Status - /// </summary> - public StatusEnum? Status { get; private set; } - - /// <summary> - /// Complete - /// </summary> - public bool? Complete { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Order.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Order() - { - } - - private Order(long? Id, long? PetId, int? Quantity, DateTime? ShipDate, StatusEnum? Status, bool? Complete) - { - - this.Id = Id; - - this.PetId = PetId; - - this.Quantity = Quantity; - - this.ShipDate = ShipDate; - - this.Status = Status; - - this.Complete = Complete; - - } - - /// <summary> - /// Returns builder of Order. - /// </summary> - /// <returns>OrderBuilder</returns> - public static OrderBuilder Builder() - { - return new OrderBuilder(); - } - - /// <summary> - /// Returns OrderBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>OrderBuilder</returns> - public OrderBuilder With() - { - return Builder() - .Id(Id) - .PetId(PetId) - .Quantity(Quantity) - .ShipDate(ShipDate) - .Status(Status) - .Complete(Complete); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Order other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Order left, Order right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Order left, Order right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Order. - /// </summary> - public sealed class OrderBuilder - { - private long? _Id; - private long? _PetId; - private int? _Quantity; - private DateTime? _ShipDate; - private StatusEnum? _Status; - private bool? _Complete; - - internal OrderBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - _Complete = false; - } - - /// <summary> - /// Sets value for Order.Id property. - /// </summary> - /// <param name="value">Id</param> - public OrderBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Order.PetId property. - /// </summary> - /// <param name="value">PetId</param> - public OrderBuilder PetId(long? value) - { - _PetId = value; - return this; - } - - /// <summary> - /// Sets value for Order.Quantity property. - /// </summary> - /// <param name="value">Quantity</param> - public OrderBuilder Quantity(int? value) - { - _Quantity = value; - return this; - } - - /// <summary> - /// Sets value for Order.ShipDate property. - /// </summary> - /// <param name="value">ShipDate</param> - public OrderBuilder ShipDate(DateTime? value) - { - _ShipDate = value; - return this; - } - - /// <summary> - /// Sets value for Order.Status property. - /// </summary> - /// <param name="value">Order Status</param> - public OrderBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - /// <summary> - /// Sets value for Order.Complete property. - /// </summary> - /// <param name="value">Complete</param> - public OrderBuilder Complete(bool? value) - { - _Complete = value; - return this; - } - - - /// <summary> - /// Builds instance of Order. - /// </summary> - /// <returns>Order</returns> - public Order Build() - { - Validate(); - return new Order( - Id: _Id, - PetId: _PetId, - Quantity: _Quantity, - ShipDate: _ShipDate, - Status: _Status, - Complete: _Complete - ); - } - - private void Validate() - { - } - } - - - public enum StatusEnum { Placed, Approved, Delivered }; - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Pet.cs deleted file mode 100644 index a9e839bb969..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Pet.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A pet for sale in the pet store - /// </summary> - public sealed class Pet: IEquatable<Pet> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Category - /// </summary> - public Category Category { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - /// <summary> - /// PhotoUrls - /// </summary> - public List<string> PhotoUrls { get; private set; } - - /// <summary> - /// Tags - /// </summary> - public List<Tag> Tags { get; private set; } - - /// <summary> - /// pet status in the store - /// </summary> - public StatusEnum? Status { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Pet.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Pet() - { - } - - private Pet(long? Id, Category Category, string Name, List<string> PhotoUrls, List<Tag> Tags, StatusEnum? Status) - { - - this.Id = Id; - - this.Category = Category; - - this.Name = Name; - - this.PhotoUrls = PhotoUrls; - - this.Tags = Tags; - - this.Status = Status; - - } - - /// <summary> - /// Returns builder of Pet. - /// </summary> - /// <returns>PetBuilder</returns> - public static PetBuilder Builder() - { - return new PetBuilder(); - } - - /// <summary> - /// Returns PetBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>PetBuilder</returns> - public PetBuilder With() - { - return Builder() - .Id(Id) - .Category(Category) - .Name(Name) - .PhotoUrls(PhotoUrls) - .Tags(Tags) - .Status(Status); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Pet other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Pet left, Pet right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Pet left, Pet right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Pet. - /// </summary> - public sealed class PetBuilder - { - private long? _Id; - private Category _Category; - private string _Name; - private List<string> _PhotoUrls; - private List<Tag> _Tags; - private StatusEnum? _Status; - - internal PetBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Pet.Id property. - /// </summary> - /// <param name="value">Id</param> - public PetBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Category property. - /// </summary> - /// <param name="value">Category</param> - public PetBuilder Category(Category value) - { - _Category = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Name property. - /// </summary> - /// <param name="value">Name</param> - public PetBuilder Name(string value) - { - _Name = value; - return this; - } - - /// <summary> - /// Sets value for Pet.PhotoUrls property. - /// </summary> - /// <param name="value">PhotoUrls</param> - public PetBuilder PhotoUrls(List<string> value) - { - _PhotoUrls = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Tags property. - /// </summary> - /// <param name="value">Tags</param> - public PetBuilder Tags(List<Tag> value) - { - _Tags = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Status property. - /// </summary> - /// <param name="value">pet status in the store</param> - public PetBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - - /// <summary> - /// Builds instance of Pet. - /// </summary> - /// <returns>Pet</returns> - public Pet Build() - { - Validate(); - return new Pet( - Id: _Id, - Category: _Category, - Name: _Name, - PhotoUrls: _PhotoUrls, - Tags: _Tags, - Status: _Status - ); - } - - private void Validate() - { - if (_Name == null) - { - throw new ArgumentException("Name is a required property for Pet and cannot be null"); - } - if (_PhotoUrls == null) - { - throw new ArgumentException("PhotoUrls is a required property for Pet and cannot be null"); - } - } - } - - - public enum StatusEnum { Available, Pending, Sold }; - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Tag.cs deleted file mode 100644 index e46182c334c..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/Tag.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A tag for a pet - /// </summary> - public sealed class Tag: IEquatable<Tag> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Tag.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Tag() - { - } - - private Tag(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Tag. - /// </summary> - /// <returns>TagBuilder</returns> - public static TagBuilder Builder() - { - return new TagBuilder(); - } - - /// <summary> - /// Returns TagBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>TagBuilder</returns> - public TagBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Tag other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Tag left, Tag right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Tag left, Tag right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Tag. - /// </summary> - public sealed class TagBuilder - { - private long? _Id; - private string _Name; - - internal TagBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Tag.Id property. - /// </summary> - /// <param name="value">Id</param> - public TagBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Tag.Name property. - /// </summary> - /// <param name="value">Name</param> - public TagBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Tag. - /// </summary> - /// <returns>Tag</returns> - public Tag Build() - { - Validate(); - return new Tag( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/User.cs deleted file mode 100644 index 29c94bbfefe..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Models/User.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A User who is purchasing from the pet store - /// </summary> - public sealed class User: IEquatable<User> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Username - /// </summary> - public string Username { get; private set; } - - /// <summary> - /// FirstName - /// </summary> - public string FirstName { get; private set; } - - /// <summary> - /// LastName - /// </summary> - public string LastName { get; private set; } - - /// <summary> - /// Email - /// </summary> - public string Email { get; private set; } - - /// <summary> - /// Password - /// </summary> - public string Password { get; private set; } - - /// <summary> - /// Phone - /// </summary> - public string Phone { get; private set; } - - /// <summary> - /// User Status - /// </summary> - public int? UserStatus { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use User.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public User() - { - } - - private User(long? Id, string Username, string FirstName, string LastName, string Email, string Password, string Phone, int? UserStatus) - { - - this.Id = Id; - - this.Username = Username; - - this.FirstName = FirstName; - - this.LastName = LastName; - - this.Email = Email; - - this.Password = Password; - - this.Phone = Phone; - - this.UserStatus = UserStatus; - - } - - /// <summary> - /// Returns builder of User. - /// </summary> - /// <returns>UserBuilder</returns> - public static UserBuilder Builder() - { - return new UserBuilder(); - } - - /// <summary> - /// Returns UserBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>UserBuilder</returns> - public UserBuilder With() - { - return Builder() - .Id(Id) - .Username(Username) - .FirstName(FirstName) - .LastName(LastName) - .Email(Email) - .Password(Password) - .Phone(Phone) - .UserStatus(UserStatus); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(User other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (User left, User right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (User left, User right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of User. - /// </summary> - public sealed class UserBuilder - { - private long? _Id; - private string _Username; - private string _FirstName; - private string _LastName; - private string _Email; - private string _Password; - private string _Phone; - private int? _UserStatus; - - internal UserBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for User.Id property. - /// </summary> - /// <param name="value">Id</param> - public UserBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for User.Username property. - /// </summary> - /// <param name="value">Username</param> - public UserBuilder Username(string value) - { - _Username = value; - return this; - } - - /// <summary> - /// Sets value for User.FirstName property. - /// </summary> - /// <param name="value">FirstName</param> - public UserBuilder FirstName(string value) - { - _FirstName = value; - return this; - } - - /// <summary> - /// Sets value for User.LastName property. - /// </summary> - /// <param name="value">LastName</param> - public UserBuilder LastName(string value) - { - _LastName = value; - return this; - } - - /// <summary> - /// Sets value for User.Email property. - /// </summary> - /// <param name="value">Email</param> - public UserBuilder Email(string value) - { - _Email = value; - return this; - } - - /// <summary> - /// Sets value for User.Password property. - /// </summary> - /// <param name="value">Password</param> - public UserBuilder Password(string value) - { - _Password = value; - return this; - } - - /// <summary> - /// Sets value for User.Phone property. - /// </summary> - /// <param name="value">Phone</param> - public UserBuilder Phone(string value) - { - _Phone = value; - return this; - } - - /// <summary> - /// Sets value for User.UserStatus property. - /// </summary> - /// <param name="value">User Status</param> - public UserBuilder UserStatus(int? value) - { - _UserStatus = value; - return this; - } - - - /// <summary> - /// Builds instance of User. - /// </summary> - /// <returns>User</returns> - public User Build() - { - Validate(); - return new User( - Id: _Id, - Username: _Username, - FirstName: _FirstName, - LastName: _LastName, - Email: _Email, - Password: _Password, - Phone: _Phone, - UserStatus: _UserStatus - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/PetModule.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/PetModule.cs deleted file mode 100644 index 7ea7c760147..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/PetModule.cs +++ /dev/null @@ -1,250 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace Org.OpenAPITools._v2.Modules -{ - /// <summary> - /// Status values that need to be considered for filter - /// </summary> - public enum FindPetsByStatusStatusEnum - { - available = 1, - pending = 2, - sold = 3 - }; - - - /// <summary> - /// Module processing requests of Pet domain. - /// </summary> - public sealed class PetModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public PetModule(PetService service) : base("/v2") - { - Post["/pet", true] = async (parameters, ct) => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'AddPet'"); - - await service.AddPet(Context, body); - return new Response { ContentType = ""}; - }; - - Delete["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var apiKey = Parameters.ValueOf<string>(parameters, Context.Request, "apiKey", ParameterType.Header); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'DeletePet'"); - - await service.DeletePet(Context, petId, apiKey); - return new Response { ContentType = ""}; - }; - - Get["/pet/findByStatus", true] = async (parameters, ct) => - { - var status = Parameters.ValueOf<FindPetsByStatusStatusEnum?>(parameters, Context.Request, "status", ParameterType.Query); - Preconditions.IsNotNull(status, "Required parameter: 'status' is missing at 'FindPetsByStatus'"); - - return await service.FindPetsByStatus(Context, status).ToArray(); - }; - - Get["/pet/findByTags", true] = async (parameters, ct) => - { - var tags = Parameters.ValueOf<List<string>>(parameters, Context.Request, "tags", ParameterType.Query); - Preconditions.IsNotNull(tags, "Required parameter: 'tags' is missing at 'FindPetsByTags'"); - - return await service.FindPetsByTags(Context, tags).ToArray(); - }; - - Get["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'GetPetById'"); - - return await service.GetPetById(Context, petId); - }; - - Put["/pet", true] = async (parameters, ct) => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdatePet'"); - - await service.UpdatePet(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/pet/{petId}", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var name = Parameters.ValueOf<string>(parameters, Context.Request, "name", ParameterType.Undefined); - var status = Parameters.ValueOf<string>(parameters, Context.Request, "status", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UpdatePetWithForm'"); - - await service.UpdatePetWithForm(Context, petId, name, status); - return new Response { ContentType = ""}; - }; - - Post["/pet/{petId}/uploadImage", true] = async (parameters, ct) => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var additionalMetadata = Parameters.ValueOf<string>(parameters, Context.Request, "additionalMetadata", ParameterType.Undefined); - var file = Parameters.ValueOf<System.IO.Stream>(parameters, Context.Request, "file", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UploadFile'"); - - return await service.UploadFile(Context, petId, additionalMetadata, file); - }; - } - } - - /// <summary> - /// Service handling Pet requests. - /// </summary> - public interface PetService - { - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - Task AddPet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional)</param> - /// <returns></returns> - Task DeletePet(NancyContext context, long? petId, string apiKey); - - /// <summary> - /// Multiple status values can be provided with comma separated strings - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="status">Status values that need to be considered for filter</param> - /// <returns>List<Pet></returns> - Task<List<Pet>> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status); - - /// <summary> - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="tags">Tags to filter by</param> - /// <returns>List<Pet></returns> - [Obsolete] - Task<List<Pet>> FindPetsByTags(NancyContext context, List<string> tags); - - /// <summary> - /// Returns a single pet - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to return</param> - /// <returns>Pet</returns> - Task<Pet> GetPetById(NancyContext context, long? petId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - Task UpdatePet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet that needs to be updated</param> - /// <param name="name">Updated name of the pet (optional)</param> - /// <param name="status">Updated status of the pet (optional)</param> - /// <returns></returns> - Task UpdatePetWithForm(NancyContext context, long? petId, string name, string status); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to update</param> - /// <param name="additionalMetadata">Additional data to pass to server (optional)</param> - /// <param name="file">file to upload (optional)</param> - /// <returns>ApiResponse</returns> - Task<ApiResponse> UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file); - } - - /// <summary> - /// Abstraction of PetService. - /// </summary> - public abstract class AbstractPetService: PetService - { - public virtual Task AddPet(NancyContext context, Pet body) - { - return AddPet(body); - } - - public virtual Task DeletePet(NancyContext context, long? petId, string apiKey) - { - return DeletePet(petId, apiKey); - } - - public virtual Task<List<Pet>> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status) - { - return FindPetsByStatus(status); - } - - [Obsolete] - public virtual Task<List<Pet>> FindPetsByTags(NancyContext context, List<string> tags) - { - return FindPetsByTags(tags); - } - - public virtual Task<Pet> GetPetById(NancyContext context, long? petId) - { - return GetPetById(petId); - } - - public virtual Task UpdatePet(NancyContext context, Pet body) - { - return UpdatePet(body); - } - - public virtual Task UpdatePetWithForm(NancyContext context, long? petId, string name, string status) - { - return UpdatePetWithForm(petId, name, status); - } - - public virtual Task<ApiResponse> UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file) - { - return UploadFile(petId, additionalMetadata, file); - } - - protected abstract Task AddPet(Pet body); - - protected abstract Task DeletePet(long? petId, string apiKey); - - protected abstract Task<List<Pet>> FindPetsByStatus(FindPetsByStatusStatusEnum? status); - - [Obsolete] - protected abstract Task<List<Pet>> FindPetsByTags(List<string> tags); - - protected abstract Task<Pet> GetPetById(long? petId); - - protected abstract Task UpdatePet(Pet body); - - protected abstract Task UpdatePetWithForm(long? petId, string name, string status); - - protected abstract Task<ApiResponse> UploadFile(long? petId, string additionalMetadata, System.IO.Stream file); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/StoreModule.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/StoreModule.cs deleted file mode 100644 index eed0645da35..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/StoreModule.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace Org.OpenAPITools._v2.Modules -{ - - /// <summary> - /// Module processing requests of Store domain. - /// </summary> - public sealed class StoreModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public StoreModule(StoreService service) : base("/v2") - { - Delete["/store/order/{orderId}", true] = async (parameters, ct) => - { - var orderId = Parameters.ValueOf<string>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'DeleteOrder'"); - - await service.DeleteOrder(Context, orderId); - return new Response { ContentType = ""}; - }; - - Get["/store/inventory", true] = async (parameters, ct) => - { - - return await service.GetInventory(Context); - }; - - Get["/store/order/{orderId}", true] = async (parameters, ct) => - { - var orderId = Parameters.ValueOf<long?>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'GetOrderById'"); - - return await service.GetOrderById(Context, orderId); - }; - - Post["/store/order", true] = async (parameters, ct) => - { - var body = this.Bind<Order>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'PlaceOrder'"); - - return await service.PlaceOrder(Context, body); - }; - } - } - - /// <summary> - /// Service handling Store requests. - /// </summary> - public interface StoreService - { - /// <summary> - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of the order that needs to be deleted</param> - /// <returns></returns> - Task DeleteOrder(NancyContext context, string orderId); - - /// <summary> - /// Returns a map of status codes to quantities - /// </summary> - /// <param name="context">Context of request</param> - /// <returns>Dictionary<string, int?></returns> - Task<Dictionary<string, int?>> GetInventory(NancyContext context); - - /// <summary> - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of pet that needs to be fetched</param> - /// <returns>Order</returns> - Task<Order> GetOrderById(NancyContext context, long? orderId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">order placed for purchasing the pet</param> - /// <returns>Order</returns> - Task<Order> PlaceOrder(NancyContext context, Order body); - } - - /// <summary> - /// Abstraction of StoreService. - /// </summary> - public abstract class AbstractStoreService: StoreService - { - public virtual Task DeleteOrder(NancyContext context, string orderId) - { - return DeleteOrder(orderId); - } - - public virtual Task<Dictionary<string, int?>> GetInventory(NancyContext context) - { - return GetInventory(); - } - - public virtual Task<Order> GetOrderById(NancyContext context, long? orderId) - { - return GetOrderById(orderId); - } - - public virtual Task<Order> PlaceOrder(NancyContext context, Order body) - { - return PlaceOrder(body); - } - - protected abstract Task DeleteOrder(string orderId); - - protected abstract Task<Dictionary<string, int?>> GetInventory(); - - protected abstract Task<Order> GetOrderById(long? orderId); - - protected abstract Task<Order> PlaceOrder(Order body); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/UserModule.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/UserModule.cs deleted file mode 100644 index 23d99c214e4..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Modules/UserModule.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; -using System.Threading.Tasks; - -namespace Org.OpenAPITools._v2.Modules -{ - - /// <summary> - /// Module processing requests of User domain. - /// </summary> - public sealed class UserModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public UserModule(UserService service) : base("/v2") - { - Post["/user", true] = async (parameters, ct) => - { - var body = this.Bind<User>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUser'"); - - await service.CreateUser(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/user/createWithArray", true] = async (parameters, ct) => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithArrayInput'"); - - await service.CreateUsersWithArrayInput(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/user/createWithList", true] = async (parameters, ct) => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithListInput'"); - - await service.CreateUsersWithListInput(Context, body); - return new Response { ContentType = ""}; - }; - - Delete["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'DeleteUser'"); - - await service.DeleteUser(Context, username); - return new Response { ContentType = ""}; - }; - - Get["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'GetUserByName'"); - - return await service.GetUserByName(Context, username); - }; - - Get["/user/login", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Query); - var password = Parameters.ValueOf<string>(parameters, Context.Request, "password", ParameterType.Query); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'LoginUser'"); - - Preconditions.IsNotNull(password, "Required parameter: 'password' is missing at 'LoginUser'"); - - return await service.LoginUser(Context, username, password); - }; - - Get["/user/logout", true] = async (parameters, ct) => - { - - await service.LogoutUser(Context); - return new Response { ContentType = ""}; - }; - - Put["/user/{username}", true] = async (parameters, ct) => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - var body = this.Bind<User>(); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'UpdateUser'"); - - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdateUser'"); - - await service.UpdateUser(Context, username, body); - return new Response { ContentType = ""}; - }; - } - } - - /// <summary> - /// Service handling User requests. - /// </summary> - public interface UserService - { - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Created user object</param> - /// <returns></returns> - Task CreateUser(NancyContext context, User body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - Task CreateUsersWithArrayInput(NancyContext context, List<User> body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - Task CreateUsersWithListInput(NancyContext context, List<User> body); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be deleted</param> - /// <returns></returns> - Task DeleteUser(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be fetched. Use user1 for testing.</param> - /// <returns>User</returns> - Task<User> GetUserByName(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The user name for login</param> - /// <param name="password">The password for login in clear text</param> - /// <returns>string</returns> - Task<string> LoginUser(NancyContext context, string username, string password); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <returns></returns> - Task LogoutUser(NancyContext context); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">name that need to be deleted</param> - /// <param name="body">Updated user object</param> - /// <returns></returns> - Task UpdateUser(NancyContext context, string username, User body); - } - - /// <summary> - /// Abstraction of UserService. - /// </summary> - public abstract class AbstractUserService: UserService - { - public virtual Task CreateUser(NancyContext context, User body) - { - return CreateUser(body); - } - - public virtual Task CreateUsersWithArrayInput(NancyContext context, List<User> body) - { - return CreateUsersWithArrayInput(body); - } - - public virtual Task CreateUsersWithListInput(NancyContext context, List<User> body) - { - return CreateUsersWithListInput(body); - } - - public virtual Task DeleteUser(NancyContext context, string username) - { - return DeleteUser(username); - } - - public virtual Task<User> GetUserByName(NancyContext context, string username) - { - return GetUserByName(username); - } - - public virtual Task<string> LoginUser(NancyContext context, string username, string password) - { - return LoginUser(username, password); - } - - public virtual Task LogoutUser(NancyContext context) - { - return LogoutUser(); - } - - public virtual Task UpdateUser(NancyContext context, string username, User body) - { - return UpdateUser(username, body); - } - - protected abstract Task CreateUser(User body); - - protected abstract Task CreateUsersWithArrayInput(List<User> body); - - protected abstract Task CreateUsersWithListInput(List<User> body); - - protected abstract Task DeleteUser(string username); - - protected abstract Task<User> GetUserByName(string username); - - protected abstract Task<string> LoginUser(string username, string password); - - protected abstract Task LogoutUser(); - - protected abstract Task UpdateUser(string username, User body); - } - -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.csproj deleted file mode 100644 index b26666605cd..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{768B8DC6-54EE-4D40-9B20-7857E1D742A4}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Org.OpenAPITools._v2</RootNamespace> - <AssemblyName>Org.OpenAPITools</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Debug\Org.OpenAPITools.XML</DocumentationFile> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Release\Org.OpenAPITools.XML</DocumentationFile> - </PropertyGroup> - <ItemGroup> - <Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL"> - <HintPath>..\..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Sharpility, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Sharpility.1.2.2\lib\net45\Sharpility.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <HintPath>..\..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="System"/> - <Reference Include="System.Core"/> - <Reference Include="System.Xml.Linq"/> - <Reference Include="System.Data.DataSetExtensions"/> - <Reference Include="Microsoft.CSharp"/> - <Reference Include="System.Data"/> - <Reference Include="System.Runtime.Serialization"/> - <Reference Include="System.Xml"/> - </ItemGroup> - <ItemGroup> - <Compile Include="**\*.cs" Exclude="obj\**"/> - </ItemGroup> - <ItemGroup> - <Content Include="packages.config"/> - </ItemGroup> - <Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets"/> -</Project> - diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.nuspec deleted file mode 100644 index d4ee2fc102a..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<package> - <metadata> - <id>Org.OpenAPITools</id> - <title>Org.OpenAPITools</title> - <version>1.0.0</version> - <authors>openapi-generator</authors> - <owners>openapi-generator</owners> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>NancyFx Org.OpenAPITools API</description> - <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> - </metadata> -</package> \ No newline at end of file diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/LocalDateConverter.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/LocalDateConverter.cs deleted file mode 100644 index dd90cbf5133..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/LocalDateConverter.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Nancy.Bootstrapper; -using Nancy.Json; -using NodaTime; -using NodaTime.Text; -using System; -using System.Collections.Generic; - -namespace Org.OpenAPITools._v2.Utils -{ - /// <summary> - /// (De)serializes a <see cref="NodaTime.LocalDate"/> to a string using - /// the <a href="https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14">RFC3339</a> - /// <code>full-date</code> format. - /// </summary> - public class LocalDateConverter : JavaScriptPrimitiveConverter, IApplicationStartup - { - public override IEnumerable<Type> SupportedTypes - { - get - { - yield return typeof(LocalDate); - yield return typeof(LocalDate?); - } - } - - public void Initialize(IPipelines pipelines) - { - JsonSettings.PrimitiveConverters.Add(new LocalDateConverter()); - } - - - public override object Serialize(object obj, JavaScriptSerializer serializer) - { - if (obj is LocalDate) - { - LocalDate localDate = (LocalDate)obj; - return LocalDatePattern.IsoPattern.Format(localDate); - } - return null; - } - - public override object Deserialize(object primitiveValue, Type type, JavaScriptSerializer serializer) - { - if ((type == typeof(LocalDate) || type == typeof(LocalDate?)) && primitiveValue is string) - { - try - { - return LocalDatePattern.IsoPattern.Parse(primitiveValue as string).GetValueOrThrow(); - } - catch { } - } - return null; - } - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/Parameters.cs b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/Parameters.cs deleted file mode 100644 index 847527a2dbb..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/Utils/Parameters.cs +++ /dev/null @@ -1,450 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Nancy; -using NodaTime; -using NodaTime.Text; -using Sharpility.Base; -using Sharpility.Extensions; -using Sharpility.Util; - -namespace Org.OpenAPITools._v2.Utils -{ - internal static class Parameters - { - private static readonly IDictionary<Type, Func<Parameter, object>> Parsers = CreateParsers(); - - internal static TValue ValueOf<TValue>(dynamic parameters, Request request, string name, ParameterType parameterType) - { - var valueType = typeof(TValue); - var valueUnderlyingType = Nullable.GetUnderlyingType(valueType); - var isNullable = default(TValue) == null; - string value = RawValueOf(parameters, request, name, parameterType); - Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name)); - if (value == null && isNullable) - { - return default(TValue); - } - if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum)) - { - return EnumValueOf<TValue>(name, value); - } - return ValueOf<TValue>(parameters, name, value, valueType, request, parameterType); - } - - private static string RawValueOf(dynamic parameters, Request request, string name, ParameterType parameterType) - { - try - { - switch (parameterType) - { - case ParameterType.Query: - string querValue = request.Query[name]; - return querValue; - case ParameterType.Path: - string pathValue = parameters[name]; - return pathValue; - case ParameterType.Header: - var headerValue = request.Headers[name]; - return headerValue != null ? string.Join(",", headerValue) : null; - } - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not obtain value of '{0}' parameter", name), e); - } - throw new InvalidOperationException(string.Format("Parameter with type: {0} is not supported", parameterType)); - } - - private static TValue EnumValueOf<TValue>(string name, string value) - { - var valueType = typeof(TValue); - var enumType = valueType.IsEnum ? valueType : Nullable.GetUnderlyingType(valueType); - Preconditions.IsNotNull(enumType, () => new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' to enum. Type {1} is not enum", name, valueType))); - var values = Enum.GetValues(enumType); - foreach (var entry in values) - { - if (entry.ToString().EqualsIgnoreCases(value) - || ((int)entry).ToString().EqualsIgnoreCases(value)) - { - return (TValue)entry; - } - } - throw new ArgumentException(string.Format("Parameter: '{0}' value: '{1}' is not supported. Expected one of: {2}", - name, value, Strings.ToString(values))); - } - - private static TValue ValueOf<TValue>(dynamic parameters, string name, string value, Type valueType, Request request, ParameterType parameterType) - { - var parser = Parsers.GetIfPresent(valueType); - if (parser != null) - { - return ParseValueUsing<TValue>(name, value, valueType, parser); - } - if (parameterType == ParameterType.Path) - { - return DynamicValueOf<TValue>(parameters, name); - } - if (parameterType == ParameterType.Query) - { - return DynamicValueOf<TValue>(request.Query, name); - } - throw new InvalidOperationException(string.Format("Could not get value for {0} with type {1}", name, valueType)); - } - - private static TValue ParseValueUsing<TValue>(string name, string value, Type valueType, Func<Parameter, object> parser) - { - var result = parser(Parameter.Of(name, value)); - try - { - return (TValue)result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' with value: '{1}'. " + - "Received: '{2}', expected: '{3}'.", - name, value, result.GetType(), valueType)); - } - } - - private static TValue DynamicValueOf<TValue>(dynamic parameters, string name) - { - string value = parameters[name]; - try - { - TValue result = parameters[name]; - return result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException(Strings.Format("Parameter: '{0}' value: '{1}' could not be parsed. " + - "Expected type: '{2}' is not supported", - name, value, typeof(TValue))); - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not get '{0}' value of '{1}' type dynamicly", - name, typeof(TValue)), e); - } - } - - private static IDictionary<Type, Func<Parameter, object>> CreateParsers() - { - var parsers = ImmutableDictionary.CreateBuilder<Type, Func<Parameter, object>>(); - parsers.Put(typeof(string), value => value.Value); - parsers.Put(typeof(bool), SafeParse(bool.Parse)); - parsers.Put(typeof(bool?), SafeParse(bool.Parse)); - parsers.Put(typeof(byte), SafeParse(byte.Parse)); - parsers.Put(typeof(sbyte?), SafeParse(sbyte.Parse)); - parsers.Put(typeof(short), SafeParse(short.Parse)); - parsers.Put(typeof(short?), SafeParse(short.Parse)); - parsers.Put(typeof(ushort), SafeParse(ushort.Parse)); - parsers.Put(typeof(ushort?), SafeParse(ushort.Parse)); - parsers.Put(typeof(int), SafeParse(int.Parse)); - parsers.Put(typeof(int?), SafeParse(int.Parse)); - parsers.Put(typeof(uint), SafeParse(uint.Parse)); - parsers.Put(typeof(uint?), SafeParse(uint.Parse)); - parsers.Put(typeof(long), SafeParse(long.Parse)); - parsers.Put(typeof(long?), SafeParse(long.Parse)); - parsers.Put(typeof(ulong), SafeParse(ulong.Parse)); - parsers.Put(typeof(ulong?), SafeParse(ulong.Parse)); - parsers.Put(typeof(float), SafeParse(float.Parse)); - parsers.Put(typeof(float?), SafeParse(float.Parse)); - parsers.Put(typeof(double), SafeParse(double.Parse)); - parsers.Put(typeof(double?), SafeParse(double.Parse)); - parsers.Put(typeof(decimal), SafeParse(decimal.Parse)); - parsers.Put(typeof(decimal?), SafeParse(decimal.Parse)); - parsers.Put(typeof(DateTime), SafeParse(DateTime.Parse)); - parsers.Put(typeof(DateTime?), SafeParse(DateTime.Parse)); - parsers.Put(typeof(TimeSpan), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(TimeSpan?), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(ZonedDateTime), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(ZonedDateTime?), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(LocalDate), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalDate?), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalTime), SafeParse(ParseLocalTime)); - parsers.Put(typeof(LocalTime?), SafeParse(ParseLocalTime)); - - parsers.Put(typeof(IEnumerable<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(ICollection<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(IList<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(List<string>), ListParse(value => value)); - parsers.Put(typeof(ISet<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(HashSet<string>), SetParse(value => value)); - - parsers.Put(typeof(IEnumerable<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(ICollection<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(IList<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(List<bool?>), NullableListParse(bool.Parse)); - parsers.Put(typeof(ISet<bool?>), NullableImmutableSetParse(bool.Parse)); - parsers.Put(typeof(HashSet<bool?>), NullableSetParse(bool.Parse)); - - parsers.Put(typeof(IEnumerable<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(ICollection<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(IList<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(List<byte>), ListParse(byte.Parse)); - parsers.Put(typeof(ISet<byte>), ImmutableSetParse(byte.Parse)); - parsers.Put(typeof(HashSet<byte>), SetParse(byte.Parse)); - - parsers.Put(typeof(IEnumerable<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(ICollection<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(IList<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(List<sbyte>), ListParse(sbyte.Parse)); - parsers.Put(typeof(ISet<sbyte>), ImmutableSetParse(sbyte.Parse)); - parsers.Put(typeof(HashSet<sbyte>), SetParse(sbyte.Parse)); - - parsers.Put(typeof(IEnumerable<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(ICollection<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(IList<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(List<short>), ListParse(short.Parse)); - parsers.Put(typeof(ISet<short>), ImmutableSetParse(short.Parse)); - parsers.Put(typeof(HashSet<short>), SetParse(short.Parse)); - - parsers.Put(typeof(IEnumerable<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(ICollection<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(IList<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(List<ushort>), ListParse(ushort.Parse)); - parsers.Put(typeof(ISet<ushort>), ImmutableSetParse(ushort.Parse)); - parsers.Put(typeof(HashSet<ushort>), SetParse(ushort.Parse)); - - parsers.Put(typeof(IEnumerable<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(ICollection<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(IList<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(List<int?>), NullableListParse(int.Parse)); - parsers.Put(typeof(ISet<int?>), NullableImmutableSetParse(int.Parse)); - parsers.Put(typeof(HashSet<int?>), NullableSetParse(int.Parse)); - - parsers.Put(typeof(IEnumerable<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(ICollection<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(IList<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(List<uint>), ListParse(uint.Parse)); - parsers.Put(typeof(ISet<uint>), ImmutableSetParse(uint.Parse)); - parsers.Put(typeof(HashSet<uint>), SetParse(uint.Parse)); - - parsers.Put(typeof(IEnumerable<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(ICollection<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(IList<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(List<long?>), NullableListParse(long.Parse)); - parsers.Put(typeof(ISet<long?>), NullableImmutableSetParse(long.Parse)); - parsers.Put(typeof(HashSet<long?>), NullableSetParse(long.Parse)); - - parsers.Put(typeof(IEnumerable<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(ICollection<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(IList<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(List<ulong>), ListParse(ulong.Parse)); - parsers.Put(typeof(ISet<ulong>), ImmutableSetParse(ulong.Parse)); - parsers.Put(typeof(HashSet<ulong>), SetParse(ulong.Parse)); - - parsers.Put(typeof(IEnumerable<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(ICollection<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(IList<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(List<float?>), NullableListParse(float.Parse)); - parsers.Put(typeof(ISet<float?>), NullableImmutableSetParse(float.Parse)); - parsers.Put(typeof(HashSet<float?>), NullableSetParse(float.Parse)); - - parsers.Put(typeof(IEnumerable<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(ICollection<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(IList<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(List<double?>), NullableListParse(double.Parse)); - parsers.Put(typeof(ISet<double?>), NullableImmutableSetParse(double.Parse)); - parsers.Put(typeof(HashSet<double?>), NullableSetParse(double.Parse)); - - parsers.Put(typeof(IEnumerable<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(ICollection<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(IList<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(List<decimal?>), NullableListParse(decimal.Parse)); - parsers.Put(typeof(ISet<decimal?>), NullableImmutableSetParse(decimal.Parse)); - parsers.Put(typeof(HashSet<decimal?>), NullableSetParse(decimal.Parse)); - - parsers.Put(typeof(IEnumerable<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(ICollection<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(IList<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(List<DateTime?>), NullableListParse(DateTime.Parse)); - parsers.Put(typeof(ISet<DateTime?>), NullableImmutableSetParse(DateTime.Parse)); - parsers.Put(typeof(HashSet<DateTime?>), NullableSetParse(DateTime.Parse)); - - parsers.Put(typeof(IEnumerable<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(ICollection<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(IList<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(List<TimeSpan>), ListParse(TimeSpan.Parse)); - parsers.Put(typeof(ISet<TimeSpan>), ImmutableSetParse(TimeSpan.Parse)); - parsers.Put(typeof(HashSet<TimeSpan>), SetParse(TimeSpan.Parse)); - - return parsers.ToImmutableDictionary(); - } - - private static Func<Parameter, object> SafeParse<T>(Func<string, T> parse) - { - return parameter => - { - try - { - return parse(parameter.Value); - } - catch (OverflowException) - { - throw ParameterOutOfRange(parameter, typeof(T)); - } - catch (FormatException) - { - throw InvalidParameterFormat(parameter, typeof(T)); - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse parameter: '{0}' with value: '{1}' to {2}", - parameter.Name, parameter.Value, typeof(T)), e); - } - }; - } - - private static Func<Parameter, object> NullableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new List<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToList(); - }; - } - - private static Func<Parameter, object> NullableImmutableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Lists.EmptyList<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableList(); - }; - } - - private static Func<Parameter, object> NullableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return SetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> SetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new HashSet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToSet(); - }; - } - - private static Func<Parameter, object> NullableImmutableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableSetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableSetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Sets.EmptySet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableHashSet(); - }; - } - - private static ZonedDateTime ParseZonedDateTime(string value) - { - var dateTime = DateTime.Parse(value); - return new ZonedDateTime(Instant.FromDateTimeUtc(dateTime.ToUniversalTime()), DateTimeZone.Utc); - } - - private static LocalDate ParseLocalDate(string value) - { - return LocalDatePattern.IsoPattern.Parse(value).Value; - } - - private static LocalTime ParseLocalTime(string value) - { - return LocalTimePattern.ExtendedIsoPattern.Parse(value).Value; - } - - private static ArgumentException ParameterOutOfRange(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query: '{0}' value: '{1}' is out of range for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static ArgumentException InvalidParameterFormat(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query '{0}' value: '{1}' format is invalid for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static IEnumerable<T> ParseCollection<T>(string value, Func<string, T> itemParser) - { - var results = value.Split(new[] { ',' }, StringSplitOptions.None) - .Where(it => it != null) - .Select(it => it.Trim()) - .Select(itemParser); - return results; - } - - public static T? ToNullable<T>(this string s, Func<string, T> itemParser) where T : struct - { - T? result = new T?(); - try - { - if (!string.IsNullOrEmpty(s) && s.Trim().Length > 0) - { - result = itemParser(s); - } - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse value: '{0}' to nullable: '{1}'", s, typeof(T).ToString()), e); - } - return result; - } - - private class Parameter - { - internal string Name { get; private set; } - internal string Value { get; private set; } - - private Parameter(string name, string value) - { - Name = name; - Value = value; - } - - internal static Parameter Of(string name, string value) - { - return new Parameter(name, value); - } - } - } - - internal enum ParameterType - { - Undefined, - Query, - Path, - Header - } -} diff --git a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/packages.config b/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/packages.config deleted file mode 100644 index e3401566e5d..00000000000 --- a/samples/server/petstore/nancyfx-async/src/Org.OpenAPITools/packages.config +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="Nancy" version="1.4.3" targetFramework="net45" /> - <package id="NodaTime" version="1.3.1" targetFramework="net45" /> - <package id="Sharpility" version="1.2.2" targetFramework="net45" /> - <package id="System.Collections.Immutable" version="1.1.37" targetFramework="net45" /> -</packages> \ No newline at end of file diff --git a/samples/server/petstore/nancyfx/.gitignore b/samples/server/petstore/nancyfx/.gitignore deleted file mode 100644 index 1ee53850b84..00000000000 --- a/samples/server/petstore/nancyfx/.gitignore +++ /dev/null @@ -1,362 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd diff --git a/samples/server/petstore/nancyfx/.openapi-generator-ignore b/samples/server/petstore/nancyfx/.openapi-generator-ignore deleted file mode 100644 index c5fa491b4c5..00000000000 --- a/samples/server/petstore/nancyfx/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/samples/server/petstore/nancyfx/.openapi-generator/FILES b/samples/server/petstore/nancyfx/.openapi-generator/FILES deleted file mode 100644 index eabec10a061..00000000000 --- a/samples/server/petstore/nancyfx/.openapi-generator/FILES +++ /dev/null @@ -1,16 +0,0 @@ -.gitignore -Org.OpenAPITools.sln -src/Org.OpenAPITools/Models/ApiResponse.cs -src/Org.OpenAPITools/Models/Category.cs -src/Org.OpenAPITools/Models/Order.cs -src/Org.OpenAPITools/Models/Pet.cs -src/Org.OpenAPITools/Models/Tag.cs -src/Org.OpenAPITools/Models/User.cs -src/Org.OpenAPITools/Modules/PetModule.cs -src/Org.OpenAPITools/Modules/StoreModule.cs -src/Org.OpenAPITools/Modules/UserModule.cs -src/Org.OpenAPITools/Org.OpenAPITools.csproj -src/Org.OpenAPITools/Org.OpenAPITools.nuspec -src/Org.OpenAPITools/Utils/LocalDateConverter.cs -src/Org.OpenAPITools/Utils/Parameters.cs -src/Org.OpenAPITools/packages.config diff --git a/samples/server/petstore/nancyfx/.openapi-generator/VERSION b/samples/server/petstore/nancyfx/.openapi-generator/VERSION deleted file mode 100644 index d99e7162d01..00000000000 --- a/samples/server/petstore/nancyfx/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/nancyfx/Org.OpenAPITools.sln b/samples/server/petstore/nancyfx/Org.OpenAPITools.sln deleted file mode 100644 index 757078a1383..00000000000 --- a/samples/server/petstore/nancyfx/Org.OpenAPITools.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.0.0 -MinimumVisualStudioVersion = 10.0.0.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{768B8DC6-54EE-4D40-9B20-7857E1D742A4}" -EndProject -Global -GlobalSection(SolutionConfigurationPlatforms) = preSolution -Debug|Any CPU = Debug|Any CPU -Release|Any CPU = Release|Any CPU -EndGlobalSection -GlobalSection(ProjectConfigurationPlatforms) = postSolution -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Debug|Any CPU.Build.0 = Debug|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Release|Any CPU.ActiveCfg = Release|Any CPU -{768B8DC6-54EE-4D40-9B20-7857E1D742A4}.Release|Any CPU.Build.0 = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU -{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU -EndGlobalSection -GlobalSection(SolutionProperties) = preSolution -HideSolutionNode = FALSE -EndGlobalSection -EndGlobal \ No newline at end of file diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/ApiResponse.cs deleted file mode 100644 index 2c35c0c5fd9..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/ApiResponse.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// Describes the result of uploading an image resource - /// </summary> - public sealed class ApiResponse: IEquatable<ApiResponse> - { - /// <summary> - /// Code - /// </summary> - public int? Code { get; private set; } - - /// <summary> - /// Type - /// </summary> - public string Type { get; private set; } - - /// <summary> - /// Message - /// </summary> - public string Message { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use ApiResponse.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public ApiResponse() - { - } - - private ApiResponse(int? Code, string Type, string Message) - { - - this.Code = Code; - - this.Type = Type; - - this.Message = Message; - - } - - /// <summary> - /// Returns builder of ApiResponse. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public static ApiResponseBuilder Builder() - { - return new ApiResponseBuilder(); - } - - /// <summary> - /// Returns ApiResponseBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>ApiResponseBuilder</returns> - public ApiResponseBuilder With() - { - return Builder() - .Code(Code) - .Type(Type) - .Message(Message); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(ApiResponse other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (ApiResponse left, ApiResponse right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (ApiResponse. - /// </summary> - /// <param name="left">Compared (ApiResponse</param> - /// <param name="right">Compared (ApiResponse</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (ApiResponse left, ApiResponse right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of ApiResponse. - /// </summary> - public sealed class ApiResponseBuilder - { - private int? _Code; - private string _Type; - private string _Message; - - internal ApiResponseBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for ApiResponse.Code property. - /// </summary> - /// <param name="value">Code</param> - public ApiResponseBuilder Code(int? value) - { - _Code = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Type property. - /// </summary> - /// <param name="value">Type</param> - public ApiResponseBuilder Type(string value) - { - _Type = value; - return this; - } - - /// <summary> - /// Sets value for ApiResponse.Message property. - /// </summary> - /// <param name="value">Message</param> - public ApiResponseBuilder Message(string value) - { - _Message = value; - return this; - } - - - /// <summary> - /// Builds instance of ApiResponse. - /// </summary> - /// <returns>ApiResponse</returns> - public ApiResponse Build() - { - Validate(); - return new ApiResponse( - Code: _Code, - Type: _Type, - Message: _Message - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Category.cs deleted file mode 100644 index 3cadeec39fe..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Category.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A category for a pet - /// </summary> - public sealed class Category: IEquatable<Category> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Category.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Category() - { - } - - private Category(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Category. - /// </summary> - /// <returns>CategoryBuilder</returns> - public static CategoryBuilder Builder() - { - return new CategoryBuilder(); - } - - /// <summary> - /// Returns CategoryBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>CategoryBuilder</returns> - public CategoryBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Category other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Category left, Category right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Category. - /// </summary> - /// <param name="left">Compared (Category</param> - /// <param name="right">Compared (Category</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Category left, Category right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Category. - /// </summary> - public sealed class CategoryBuilder - { - private long? _Id; - private string _Name; - - internal CategoryBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Category.Id property. - /// </summary> - /// <param name="value">Id</param> - public CategoryBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Category.Name property. - /// </summary> - /// <param name="value">Name</param> - public CategoryBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Category. - /// </summary> - /// <returns>Category</returns> - public Category Build() - { - Validate(); - return new Category( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Order.cs deleted file mode 100644 index 3ef8e9133c7..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Order.cs +++ /dev/null @@ -1,247 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// An order for a pets from the pet store - /// </summary> - public sealed class Order: IEquatable<Order> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// PetId - /// </summary> - public long? PetId { get; private set; } - - /// <summary> - /// Quantity - /// </summary> - public int? Quantity { get; private set; } - - /// <summary> - /// ShipDate - /// </summary> - public DateTime? ShipDate { get; private set; } - - /// <summary> - /// Order Status - /// </summary> - public StatusEnum? Status { get; private set; } - - /// <summary> - /// Complete - /// </summary> - public bool? Complete { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Order.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Order() - { - } - - private Order(long? Id, long? PetId, int? Quantity, DateTime? ShipDate, StatusEnum? Status, bool? Complete) - { - - this.Id = Id; - - this.PetId = PetId; - - this.Quantity = Quantity; - - this.ShipDate = ShipDate; - - this.Status = Status; - - this.Complete = Complete; - - } - - /// <summary> - /// Returns builder of Order. - /// </summary> - /// <returns>OrderBuilder</returns> - public static OrderBuilder Builder() - { - return new OrderBuilder(); - } - - /// <summary> - /// Returns OrderBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>OrderBuilder</returns> - public OrderBuilder With() - { - return Builder() - .Id(Id) - .PetId(PetId) - .Quantity(Quantity) - .ShipDate(ShipDate) - .Status(Status) - .Complete(Complete); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Order other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Order left, Order right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Order. - /// </summary> - /// <param name="left">Compared (Order</param> - /// <param name="right">Compared (Order</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Order left, Order right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Order. - /// </summary> - public sealed class OrderBuilder - { - private long? _Id; - private long? _PetId; - private int? _Quantity; - private DateTime? _ShipDate; - private StatusEnum? _Status; - private bool? _Complete; - - internal OrderBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - _Complete = false; - } - - /// <summary> - /// Sets value for Order.Id property. - /// </summary> - /// <param name="value">Id</param> - public OrderBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Order.PetId property. - /// </summary> - /// <param name="value">PetId</param> - public OrderBuilder PetId(long? value) - { - _PetId = value; - return this; - } - - /// <summary> - /// Sets value for Order.Quantity property. - /// </summary> - /// <param name="value">Quantity</param> - public OrderBuilder Quantity(int? value) - { - _Quantity = value; - return this; - } - - /// <summary> - /// Sets value for Order.ShipDate property. - /// </summary> - /// <param name="value">ShipDate</param> - public OrderBuilder ShipDate(DateTime? value) - { - _ShipDate = value; - return this; - } - - /// <summary> - /// Sets value for Order.Status property. - /// </summary> - /// <param name="value">Order Status</param> - public OrderBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - /// <summary> - /// Sets value for Order.Complete property. - /// </summary> - /// <param name="value">Complete</param> - public OrderBuilder Complete(bool? value) - { - _Complete = value; - return this; - } - - - /// <summary> - /// Builds instance of Order. - /// </summary> - /// <returns>Order</returns> - public Order Build() - { - Validate(); - return new Order( - Id: _Id, - PetId: _PetId, - Quantity: _Quantity, - ShipDate: _ShipDate, - Status: _Status, - Complete: _Complete - ); - } - - private void Validate() - { - } - } - - - public enum StatusEnum { Placed, Approved, Delivered }; - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Pet.cs deleted file mode 100644 index a9e839bb969..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Pet.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A pet for sale in the pet store - /// </summary> - public sealed class Pet: IEquatable<Pet> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Category - /// </summary> - public Category Category { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - /// <summary> - /// PhotoUrls - /// </summary> - public List<string> PhotoUrls { get; private set; } - - /// <summary> - /// Tags - /// </summary> - public List<Tag> Tags { get; private set; } - - /// <summary> - /// pet status in the store - /// </summary> - public StatusEnum? Status { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Pet.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Pet() - { - } - - private Pet(long? Id, Category Category, string Name, List<string> PhotoUrls, List<Tag> Tags, StatusEnum? Status) - { - - this.Id = Id; - - this.Category = Category; - - this.Name = Name; - - this.PhotoUrls = PhotoUrls; - - this.Tags = Tags; - - this.Status = Status; - - } - - /// <summary> - /// Returns builder of Pet. - /// </summary> - /// <returns>PetBuilder</returns> - public static PetBuilder Builder() - { - return new PetBuilder(); - } - - /// <summary> - /// Returns PetBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>PetBuilder</returns> - public PetBuilder With() - { - return Builder() - .Id(Id) - .Category(Category) - .Name(Name) - .PhotoUrls(PhotoUrls) - .Tags(Tags) - .Status(Status); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Pet other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Pet left, Pet right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Pet. - /// </summary> - /// <param name="left">Compared (Pet</param> - /// <param name="right">Compared (Pet</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Pet left, Pet right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Pet. - /// </summary> - public sealed class PetBuilder - { - private long? _Id; - private Category _Category; - private string _Name; - private List<string> _PhotoUrls; - private List<Tag> _Tags; - private StatusEnum? _Status; - - internal PetBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Pet.Id property. - /// </summary> - /// <param name="value">Id</param> - public PetBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Category property. - /// </summary> - /// <param name="value">Category</param> - public PetBuilder Category(Category value) - { - _Category = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Name property. - /// </summary> - /// <param name="value">Name</param> - public PetBuilder Name(string value) - { - _Name = value; - return this; - } - - /// <summary> - /// Sets value for Pet.PhotoUrls property. - /// </summary> - /// <param name="value">PhotoUrls</param> - public PetBuilder PhotoUrls(List<string> value) - { - _PhotoUrls = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Tags property. - /// </summary> - /// <param name="value">Tags</param> - public PetBuilder Tags(List<Tag> value) - { - _Tags = value; - return this; - } - - /// <summary> - /// Sets value for Pet.Status property. - /// </summary> - /// <param name="value">pet status in the store</param> - public PetBuilder Status(StatusEnum? value) - { - _Status = value; - return this; - } - - - /// <summary> - /// Builds instance of Pet. - /// </summary> - /// <returns>Pet</returns> - public Pet Build() - { - Validate(); - return new Pet( - Id: _Id, - Category: _Category, - Name: _Name, - PhotoUrls: _PhotoUrls, - Tags: _Tags, - Status: _Status - ); - } - - private void Validate() - { - if (_Name == null) - { - throw new ArgumentException("Name is a required property for Pet and cannot be null"); - } - if (_PhotoUrls == null) - { - throw new ArgumentException("PhotoUrls is a required property for Pet and cannot be null"); - } - } - } - - - public enum StatusEnum { Available, Pending, Sold }; - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Tag.cs deleted file mode 100644 index e46182c334c..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/Tag.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A tag for a pet - /// </summary> - public sealed class Tag: IEquatable<Tag> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Name - /// </summary> - public string Name { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use Tag.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public Tag() - { - } - - private Tag(long? Id, string Name) - { - - this.Id = Id; - - this.Name = Name; - - } - - /// <summary> - /// Returns builder of Tag. - /// </summary> - /// <returns>TagBuilder</returns> - public static TagBuilder Builder() - { - return new TagBuilder(); - } - - /// <summary> - /// Returns TagBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>TagBuilder</returns> - public TagBuilder With() - { - return Builder() - .Id(Id) - .Name(Name); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(Tag other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (Tag left, Tag right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (Tag. - /// </summary> - /// <param name="left">Compared (Tag</param> - /// <param name="right">Compared (Tag</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (Tag left, Tag right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of Tag. - /// </summary> - public sealed class TagBuilder - { - private long? _Id; - private string _Name; - - internal TagBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for Tag.Id property. - /// </summary> - /// <param name="value">Id</param> - public TagBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for Tag.Name property. - /// </summary> - /// <param name="value">Name</param> - public TagBuilder Name(string value) - { - _Name = value; - return this; - } - - - /// <summary> - /// Builds instance of Tag. - /// </summary> - /// <returns>Tag</returns> - public Tag Build() - { - Validate(); - return new Tag( - Id: _Id, - Name: _Name - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/User.cs deleted file mode 100644 index 29c94bbfefe..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Models/User.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Sharpility.Extensions; -using NodaTime; - -namespace Org.OpenAPITools._v2.Models -{ - /// <summary> - /// A User who is purchasing from the pet store - /// </summary> - public sealed class User: IEquatable<User> - { - /// <summary> - /// Id - /// </summary> - public long? Id { get; private set; } - - /// <summary> - /// Username - /// </summary> - public string Username { get; private set; } - - /// <summary> - /// FirstName - /// </summary> - public string FirstName { get; private set; } - - /// <summary> - /// LastName - /// </summary> - public string LastName { get; private set; } - - /// <summary> - /// Email - /// </summary> - public string Email { get; private set; } - - /// <summary> - /// Password - /// </summary> - public string Password { get; private set; } - - /// <summary> - /// Phone - /// </summary> - public string Phone { get; private set; } - - /// <summary> - /// User Status - /// </summary> - public int? UserStatus { get; private set; } - - - /// <summary> - /// Empty constructor required by some serializers. - /// Use User.Builder() for instance creation instead. - /// </summary> - [Obsolete] - public User() - { - } - - private User(long? Id, string Username, string FirstName, string LastName, string Email, string Password, string Phone, int? UserStatus) - { - - this.Id = Id; - - this.Username = Username; - - this.FirstName = FirstName; - - this.LastName = LastName; - - this.Email = Email; - - this.Password = Password; - - this.Phone = Phone; - - this.UserStatus = UserStatus; - - } - - /// <summary> - /// Returns builder of User. - /// </summary> - /// <returns>UserBuilder</returns> - public static UserBuilder Builder() - { - return new UserBuilder(); - } - - /// <summary> - /// Returns UserBuilder with properties set. - /// Use it to change properties. - /// </summary> - /// <returns>UserBuilder</returns> - public UserBuilder With() - { - return Builder() - .Id(Id) - .Username(Username) - .FirstName(FirstName) - .LastName(LastName) - .Email(Email) - .Password(Password) - .Phone(Phone) - .UserStatus(UserStatus); - } - - public override string ToString() - { - return this.PropertiesToString(); - } - - public override bool Equals(object obj) - { - return this.EqualsByProperties(obj); - } - - public bool Equals(User other) - { - return Equals((object) other); - } - - public override int GetHashCode() - { - return this.PropertiesHash(); - } - - /// <summary> - /// Implementation of == operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are equals, false otherwise</returns> - public static bool operator == (User left, User right) - { - return Equals(left, right); - } - - /// <summary> - /// Implementation of != operator for (User. - /// </summary> - /// <param name="left">Compared (User</param> - /// <param name="right">Compared (User</param> - /// <returns>true if compared items are not equals, false otherwise</returns> - public static bool operator != (User left, User right) - { - return !Equals(left, right); - } - - /// <summary> - /// Builder of User. - /// </summary> - public sealed class UserBuilder - { - private long? _Id; - private string _Username; - private string _FirstName; - private string _LastName; - private string _Email; - private string _Password; - private string _Phone; - private int? _UserStatus; - - internal UserBuilder() - { - SetupDefaults(); - } - - private void SetupDefaults() - { - } - - /// <summary> - /// Sets value for User.Id property. - /// </summary> - /// <param name="value">Id</param> - public UserBuilder Id(long? value) - { - _Id = value; - return this; - } - - /// <summary> - /// Sets value for User.Username property. - /// </summary> - /// <param name="value">Username</param> - public UserBuilder Username(string value) - { - _Username = value; - return this; - } - - /// <summary> - /// Sets value for User.FirstName property. - /// </summary> - /// <param name="value">FirstName</param> - public UserBuilder FirstName(string value) - { - _FirstName = value; - return this; - } - - /// <summary> - /// Sets value for User.LastName property. - /// </summary> - /// <param name="value">LastName</param> - public UserBuilder LastName(string value) - { - _LastName = value; - return this; - } - - /// <summary> - /// Sets value for User.Email property. - /// </summary> - /// <param name="value">Email</param> - public UserBuilder Email(string value) - { - _Email = value; - return this; - } - - /// <summary> - /// Sets value for User.Password property. - /// </summary> - /// <param name="value">Password</param> - public UserBuilder Password(string value) - { - _Password = value; - return this; - } - - /// <summary> - /// Sets value for User.Phone property. - /// </summary> - /// <param name="value">Phone</param> - public UserBuilder Phone(string value) - { - _Phone = value; - return this; - } - - /// <summary> - /// Sets value for User.UserStatus property. - /// </summary> - /// <param name="value">User Status</param> - public UserBuilder UserStatus(int? value) - { - _UserStatus = value; - return this; - } - - - /// <summary> - /// Builds instance of User. - /// </summary> - /// <returns>User</returns> - public User Build() - { - Validate(); - return new User( - Id: _Id, - Username: _Username, - FirstName: _FirstName, - LastName: _LastName, - Email: _Email, - Password: _Password, - Phone: _Phone, - UserStatus: _UserStatus - ); - } - - private void Validate() - { - } - } - - - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/PetModule.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/PetModule.cs deleted file mode 100644 index 8dc52f8275b..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/PetModule.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; - -namespace Org.OpenAPITools._v2.Modules -{ - /// <summary> - /// Status values that need to be considered for filter - /// </summary> - public enum FindPetsByStatusStatusEnum - { - available = 1, - pending = 2, - sold = 3 - }; - - - /// <summary> - /// Module processing requests of Pet domain. - /// </summary> - public sealed class PetModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public PetModule(PetService service) : base("/v2") - { - Post["/pet"] = parameters => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'AddPet'"); - - service.AddPet(Context, body); - return new Response { ContentType = ""}; - }; - - Delete["/pet/{petId}"] = parameters => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var apiKey = Parameters.ValueOf<string>(parameters, Context.Request, "apiKey", ParameterType.Header); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'DeletePet'"); - - service.DeletePet(Context, petId, apiKey); - return new Response { ContentType = ""}; - }; - - Get["/pet/findByStatus"] = parameters => - { - var status = Parameters.ValueOf<FindPetsByStatusStatusEnum?>(parameters, Context.Request, "status", ParameterType.Query); - Preconditions.IsNotNull(status, "Required parameter: 'status' is missing at 'FindPetsByStatus'"); - - return service.FindPetsByStatus(Context, status).ToArray(); - }; - - Get["/pet/findByTags"] = parameters => - { - var tags = Parameters.ValueOf<List<string>>(parameters, Context.Request, "tags", ParameterType.Query); - Preconditions.IsNotNull(tags, "Required parameter: 'tags' is missing at 'FindPetsByTags'"); - - return service.FindPetsByTags(Context, tags).ToArray(); - }; - - Get["/pet/{petId}"] = parameters => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'GetPetById'"); - - return service.GetPetById(Context, petId); - }; - - Put["/pet"] = parameters => - { - var body = this.Bind<Pet>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdatePet'"); - - service.UpdatePet(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/pet/{petId}"] = parameters => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var name = Parameters.ValueOf<string>(parameters, Context.Request, "name", ParameterType.Undefined); - var status = Parameters.ValueOf<string>(parameters, Context.Request, "status", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UpdatePetWithForm'"); - - service.UpdatePetWithForm(Context, petId, name, status); - return new Response { ContentType = ""}; - }; - - Post["/pet/{petId}/uploadImage"] = parameters => - { - var petId = Parameters.ValueOf<long?>(parameters, Context.Request, "petId", ParameterType.Path); - var additionalMetadata = Parameters.ValueOf<string>(parameters, Context.Request, "additionalMetadata", ParameterType.Undefined); - var file = Parameters.ValueOf<System.IO.Stream>(parameters, Context.Request, "file", ParameterType.Undefined); - Preconditions.IsNotNull(petId, "Required parameter: 'petId' is missing at 'UploadFile'"); - - return service.UploadFile(Context, petId, additionalMetadata, file); - }; - } - } - - /// <summary> - /// Service handling Pet requests. - /// </summary> - public interface PetService - { - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - void AddPet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional)</param> - /// <returns></returns> - void DeletePet(NancyContext context, long? petId, string apiKey); - - /// <summary> - /// Multiple status values can be provided with comma separated strings - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="status">Status values that need to be considered for filter</param> - /// <returns>List<Pet></returns> - List<Pet> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status); - - /// <summary> - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="tags">Tags to filter by</param> - /// <returns>List<Pet></returns> - [Obsolete] - List<Pet> FindPetsByTags(NancyContext context, List<string> tags); - - /// <summary> - /// Returns a single pet - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to return</param> - /// <returns>Pet</returns> - Pet GetPetById(NancyContext context, long? petId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Pet object that needs to be added to the store</param> - /// <returns></returns> - void UpdatePet(NancyContext context, Pet body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet that needs to be updated</param> - /// <param name="name">Updated name of the pet (optional)</param> - /// <param name="status">Updated status of the pet (optional)</param> - /// <returns></returns> - void UpdatePetWithForm(NancyContext context, long? petId, string name, string status); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="petId">ID of pet to update</param> - /// <param name="additionalMetadata">Additional data to pass to server (optional)</param> - /// <param name="file">file to upload (optional)</param> - /// <returns>ApiResponse</returns> - ApiResponse UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file); - } - - /// <summary> - /// Abstraction of PetService. - /// </summary> - public abstract class AbstractPetService: PetService - { - public virtual void AddPet(NancyContext context, Pet body) - { - AddPet(body); - } - - public virtual void DeletePet(NancyContext context, long? petId, string apiKey) - { - DeletePet(petId, apiKey); - } - - public virtual List<Pet> FindPetsByStatus(NancyContext context, FindPetsByStatusStatusEnum? status) - { - return FindPetsByStatus(status); - } - - [Obsolete] - public virtual List<Pet> FindPetsByTags(NancyContext context, List<string> tags) - { - return FindPetsByTags(tags); - } - - public virtual Pet GetPetById(NancyContext context, long? petId) - { - return GetPetById(petId); - } - - public virtual void UpdatePet(NancyContext context, Pet body) - { - UpdatePet(body); - } - - public virtual void UpdatePetWithForm(NancyContext context, long? petId, string name, string status) - { - UpdatePetWithForm(petId, name, status); - } - - public virtual ApiResponse UploadFile(NancyContext context, long? petId, string additionalMetadata, System.IO.Stream file) - { - return UploadFile(petId, additionalMetadata, file); - } - - protected abstract void AddPet(Pet body); - - protected abstract void DeletePet(long? petId, string apiKey); - - protected abstract List<Pet> FindPetsByStatus(FindPetsByStatusStatusEnum? status); - - [Obsolete] - protected abstract List<Pet> FindPetsByTags(List<string> tags); - - protected abstract Pet GetPetById(long? petId); - - protected abstract void UpdatePet(Pet body); - - protected abstract void UpdatePetWithForm(long? petId, string name, string status); - - protected abstract ApiResponse UploadFile(long? petId, string additionalMetadata, System.IO.Stream file); - } - -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/StoreModule.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/StoreModule.cs deleted file mode 100644 index 0c75b02fd9a..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/StoreModule.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; - -namespace Org.OpenAPITools._v2.Modules -{ - - /// <summary> - /// Module processing requests of Store domain. - /// </summary> - public sealed class StoreModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public StoreModule(StoreService service) : base("/v2") - { - Delete["/store/order/{orderId}"] = parameters => - { - var orderId = Parameters.ValueOf<string>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'DeleteOrder'"); - - service.DeleteOrder(Context, orderId); - return new Response { ContentType = ""}; - }; - - Get["/store/inventory"] = parameters => - { - - return service.GetInventory(Context); - }; - - Get["/store/order/{orderId}"] = parameters => - { - var orderId = Parameters.ValueOf<long?>(parameters, Context.Request, "orderId", ParameterType.Path); - Preconditions.IsNotNull(orderId, "Required parameter: 'orderId' is missing at 'GetOrderById'"); - - return service.GetOrderById(Context, orderId); - }; - - Post["/store/order"] = parameters => - { - var body = this.Bind<Order>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'PlaceOrder'"); - - return service.PlaceOrder(Context, body); - }; - } - } - - /// <summary> - /// Service handling Store requests. - /// </summary> - public interface StoreService - { - /// <summary> - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of the order that needs to be deleted</param> - /// <returns></returns> - void DeleteOrder(NancyContext context, string orderId); - - /// <summary> - /// Returns a map of status codes to quantities - /// </summary> - /// <param name="context">Context of request</param> - /// <returns>Dictionary<string, int?></returns> - Dictionary<string, int?> GetInventory(NancyContext context); - - /// <summary> - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="orderId">ID of pet that needs to be fetched</param> - /// <returns>Order</returns> - Order GetOrderById(NancyContext context, long? orderId); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">order placed for purchasing the pet</param> - /// <returns>Order</returns> - Order PlaceOrder(NancyContext context, Order body); - } - - /// <summary> - /// Abstraction of StoreService. - /// </summary> - public abstract class AbstractStoreService: StoreService - { - public virtual void DeleteOrder(NancyContext context, string orderId) - { - DeleteOrder(orderId); - } - - public virtual Dictionary<string, int?> GetInventory(NancyContext context) - { - return GetInventory(); - } - - public virtual Order GetOrderById(NancyContext context, long? orderId) - { - return GetOrderById(orderId); - } - - public virtual Order PlaceOrder(NancyContext context, Order body) - { - return PlaceOrder(body); - } - - protected abstract void DeleteOrder(string orderId); - - protected abstract Dictionary<string, int?> GetInventory(); - - protected abstract Order GetOrderById(long? orderId); - - protected abstract Order PlaceOrder(Order body); - } - -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/UserModule.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/UserModule.cs deleted file mode 100644 index cc268b9a2c5..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Modules/UserModule.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using Nancy; -using Nancy.ModelBinding; -using System.Collections.Generic; -using Sharpility.Base; -using Org.OpenAPITools._v2.Models; -using Org.OpenAPITools._v2.Utils; -using NodaTime; - -namespace Org.OpenAPITools._v2.Modules -{ - - /// <summary> - /// Module processing requests of User domain. - /// </summary> - public sealed class UserModule : NancyModule - { - /// <summary> - /// Sets up HTTP methods mappings. - /// </summary> - /// <param name="service">Service handling requests</param> - public UserModule(UserService service) : base("/v2") - { - Post["/user"] = parameters => - { - var body = this.Bind<User>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUser'"); - - service.CreateUser(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/user/createWithArray"] = parameters => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithArrayInput'"); - - service.CreateUsersWithArrayInput(Context, body); - return new Response { ContentType = ""}; - }; - - Post["/user/createWithList"] = parameters => - { - var body = this.Bind<List<User>>(); - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'CreateUsersWithListInput'"); - - service.CreateUsersWithListInput(Context, body); - return new Response { ContentType = ""}; - }; - - Delete["/user/{username}"] = parameters => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'DeleteUser'"); - - service.DeleteUser(Context, username); - return new Response { ContentType = ""}; - }; - - Get["/user/{username}"] = parameters => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'GetUserByName'"); - - return service.GetUserByName(Context, username); - }; - - Get["/user/login"] = parameters => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Query); - var password = Parameters.ValueOf<string>(parameters, Context.Request, "password", ParameterType.Query); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'LoginUser'"); - - Preconditions.IsNotNull(password, "Required parameter: 'password' is missing at 'LoginUser'"); - - return service.LoginUser(Context, username, password); - }; - - Get["/user/logout"] = parameters => - { - - service.LogoutUser(Context); - return new Response { ContentType = ""}; - }; - - Put["/user/{username}"] = parameters => - { - var username = Parameters.ValueOf<string>(parameters, Context.Request, "username", ParameterType.Path); - var body = this.Bind<User>(); - Preconditions.IsNotNull(username, "Required parameter: 'username' is missing at 'UpdateUser'"); - - Preconditions.IsNotNull(body, "Required parameter: 'body' is missing at 'UpdateUser'"); - - service.UpdateUser(Context, username, body); - return new Response { ContentType = ""}; - }; - } - } - - /// <summary> - /// Service handling User requests. - /// </summary> - public interface UserService - { - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">Created user object</param> - /// <returns></returns> - void CreateUser(NancyContext context, User body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - void CreateUsersWithArrayInput(NancyContext context, List<User> body); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="body">List of user object</param> - /// <returns></returns> - void CreateUsersWithListInput(NancyContext context, List<User> body); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be deleted</param> - /// <returns></returns> - void DeleteUser(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The name that needs to be fetched. Use user1 for testing.</param> - /// <returns>User</returns> - User GetUserByName(NancyContext context, string username); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">The user name for login</param> - /// <param name="password">The password for login in clear text</param> - /// <returns>string</returns> - string LoginUser(NancyContext context, string username, string password); - - /// <summary> - /// - /// </summary> - /// <param name="context">Context of request</param> - /// <returns></returns> - void LogoutUser(NancyContext context); - - /// <summary> - /// This can only be done by the logged in user. - /// </summary> - /// <param name="context">Context of request</param> - /// <param name="username">name that need to be deleted</param> - /// <param name="body">Updated user object</param> - /// <returns></returns> - void UpdateUser(NancyContext context, string username, User body); - } - - /// <summary> - /// Abstraction of UserService. - /// </summary> - public abstract class AbstractUserService: UserService - { - public virtual void CreateUser(NancyContext context, User body) - { - CreateUser(body); - } - - public virtual void CreateUsersWithArrayInput(NancyContext context, List<User> body) - { - CreateUsersWithArrayInput(body); - } - - public virtual void CreateUsersWithListInput(NancyContext context, List<User> body) - { - CreateUsersWithListInput(body); - } - - public virtual void DeleteUser(NancyContext context, string username) - { - DeleteUser(username); - } - - public virtual User GetUserByName(NancyContext context, string username) - { - return GetUserByName(username); - } - - public virtual string LoginUser(NancyContext context, string username, string password) - { - return LoginUser(username, password); - } - - public virtual void LogoutUser(NancyContext context) - { - LogoutUser(); - } - - public virtual void UpdateUser(NancyContext context, string username, User body) - { - UpdateUser(username, body); - } - - protected abstract void CreateUser(User body); - - protected abstract void CreateUsersWithArrayInput(List<User> body); - - protected abstract void CreateUsersWithListInput(List<User> body); - - protected abstract void DeleteUser(string username); - - protected abstract User GetUserByName(string username); - - protected abstract string LoginUser(string username, string password); - - protected abstract void LogoutUser(); - - protected abstract void UpdateUser(string username, User body); - } - -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.csproj deleted file mode 100644 index b26666605cd..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{768B8DC6-54EE-4D40-9B20-7857E1D742A4}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Org.OpenAPITools._v2</RootNamespace> - <AssemblyName>Org.OpenAPITools</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Debug\Org.OpenAPITools.XML</DocumentationFile> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <DocumentationFile>bin\Release\Org.OpenAPITools.XML</DocumentationFile> - </PropertyGroup> - <ItemGroup> - <Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL"> - <HintPath>..\..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Sharpility, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\Sharpility.1.2.2\lib\net45\Sharpility.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <HintPath>..\..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="System"/> - <Reference Include="System.Core"/> - <Reference Include="System.Xml.Linq"/> - <Reference Include="System.Data.DataSetExtensions"/> - <Reference Include="Microsoft.CSharp"/> - <Reference Include="System.Data"/> - <Reference Include="System.Runtime.Serialization"/> - <Reference Include="System.Xml"/> - </ItemGroup> - <ItemGroup> - <Compile Include="**\*.cs" Exclude="obj\**"/> - </ItemGroup> - <ItemGroup> - <Content Include="packages.config"/> - </ItemGroup> - <Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets"/> -</Project> - diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.nuspec deleted file mode 100644 index d4ee2fc102a..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<package> - <metadata> - <id>Org.OpenAPITools</id> - <title>Org.OpenAPITools</title> - <version>1.0.0</version> - <authors>openapi-generator</authors> - <owners>openapi-generator</owners> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>NancyFx Org.OpenAPITools API</description> - <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> - </metadata> -</package> \ No newline at end of file diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/LocalDateConverter.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/LocalDateConverter.cs deleted file mode 100644 index dd90cbf5133..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/LocalDateConverter.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Nancy.Bootstrapper; -using Nancy.Json; -using NodaTime; -using NodaTime.Text; -using System; -using System.Collections.Generic; - -namespace Org.OpenAPITools._v2.Utils -{ - /// <summary> - /// (De)serializes a <see cref="NodaTime.LocalDate"/> to a string using - /// the <a href="https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14">RFC3339</a> - /// <code>full-date</code> format. - /// </summary> - public class LocalDateConverter : JavaScriptPrimitiveConverter, IApplicationStartup - { - public override IEnumerable<Type> SupportedTypes - { - get - { - yield return typeof(LocalDate); - yield return typeof(LocalDate?); - } - } - - public void Initialize(IPipelines pipelines) - { - JsonSettings.PrimitiveConverters.Add(new LocalDateConverter()); - } - - - public override object Serialize(object obj, JavaScriptSerializer serializer) - { - if (obj is LocalDate) - { - LocalDate localDate = (LocalDate)obj; - return LocalDatePattern.IsoPattern.Format(localDate); - } - return null; - } - - public override object Deserialize(object primitiveValue, Type type, JavaScriptSerializer serializer) - { - if ((type == typeof(LocalDate) || type == typeof(LocalDate?)) && primitiveValue is string) - { - try - { - return LocalDatePattern.IsoPattern.Parse(primitiveValue as string).GetValueOrThrow(); - } - catch { } - } - return null; - } - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/Parameters.cs b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/Parameters.cs deleted file mode 100644 index 847527a2dbb..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/Utils/Parameters.cs +++ /dev/null @@ -1,450 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Nancy; -using NodaTime; -using NodaTime.Text; -using Sharpility.Base; -using Sharpility.Extensions; -using Sharpility.Util; - -namespace Org.OpenAPITools._v2.Utils -{ - internal static class Parameters - { - private static readonly IDictionary<Type, Func<Parameter, object>> Parsers = CreateParsers(); - - internal static TValue ValueOf<TValue>(dynamic parameters, Request request, string name, ParameterType parameterType) - { - var valueType = typeof(TValue); - var valueUnderlyingType = Nullable.GetUnderlyingType(valueType); - var isNullable = default(TValue) == null; - string value = RawValueOf(parameters, request, name, parameterType); - Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name)); - if (value == null && isNullable) - { - return default(TValue); - } - if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum)) - { - return EnumValueOf<TValue>(name, value); - } - return ValueOf<TValue>(parameters, name, value, valueType, request, parameterType); - } - - private static string RawValueOf(dynamic parameters, Request request, string name, ParameterType parameterType) - { - try - { - switch (parameterType) - { - case ParameterType.Query: - string querValue = request.Query[name]; - return querValue; - case ParameterType.Path: - string pathValue = parameters[name]; - return pathValue; - case ParameterType.Header: - var headerValue = request.Headers[name]; - return headerValue != null ? string.Join(",", headerValue) : null; - } - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not obtain value of '{0}' parameter", name), e); - } - throw new InvalidOperationException(string.Format("Parameter with type: {0} is not supported", parameterType)); - } - - private static TValue EnumValueOf<TValue>(string name, string value) - { - var valueType = typeof(TValue); - var enumType = valueType.IsEnum ? valueType : Nullable.GetUnderlyingType(valueType); - Preconditions.IsNotNull(enumType, () => new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' to enum. Type {1} is not enum", name, valueType))); - var values = Enum.GetValues(enumType); - foreach (var entry in values) - { - if (entry.ToString().EqualsIgnoreCases(value) - || ((int)entry).ToString().EqualsIgnoreCases(value)) - { - return (TValue)entry; - } - } - throw new ArgumentException(string.Format("Parameter: '{0}' value: '{1}' is not supported. Expected one of: {2}", - name, value, Strings.ToString(values))); - } - - private static TValue ValueOf<TValue>(dynamic parameters, string name, string value, Type valueType, Request request, ParameterType parameterType) - { - var parser = Parsers.GetIfPresent(valueType); - if (parser != null) - { - return ParseValueUsing<TValue>(name, value, valueType, parser); - } - if (parameterType == ParameterType.Path) - { - return DynamicValueOf<TValue>(parameters, name); - } - if (parameterType == ParameterType.Query) - { - return DynamicValueOf<TValue>(request.Query, name); - } - throw new InvalidOperationException(string.Format("Could not get value for {0} with type {1}", name, valueType)); - } - - private static TValue ParseValueUsing<TValue>(string name, string value, Type valueType, Func<Parameter, object> parser) - { - var result = parser(Parameter.Of(name, value)); - try - { - return (TValue)result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException( - string.Format("Could not parse parameter: '{0}' with value: '{1}'. " + - "Received: '{2}', expected: '{3}'.", - name, value, result.GetType(), valueType)); - } - } - - private static TValue DynamicValueOf<TValue>(dynamic parameters, string name) - { - string value = parameters[name]; - try - { - TValue result = parameters[name]; - return result; - } - catch (InvalidCastException) - { - throw new InvalidOperationException(Strings.Format("Parameter: '{0}' value: '{1}' could not be parsed. " + - "Expected type: '{2}' is not supported", - name, value, typeof(TValue))); - } - catch (Exception e) - { - throw new InvalidOperationException(string.Format("Could not get '{0}' value of '{1}' type dynamicly", - name, typeof(TValue)), e); - } - } - - private static IDictionary<Type, Func<Parameter, object>> CreateParsers() - { - var parsers = ImmutableDictionary.CreateBuilder<Type, Func<Parameter, object>>(); - parsers.Put(typeof(string), value => value.Value); - parsers.Put(typeof(bool), SafeParse(bool.Parse)); - parsers.Put(typeof(bool?), SafeParse(bool.Parse)); - parsers.Put(typeof(byte), SafeParse(byte.Parse)); - parsers.Put(typeof(sbyte?), SafeParse(sbyte.Parse)); - parsers.Put(typeof(short), SafeParse(short.Parse)); - parsers.Put(typeof(short?), SafeParse(short.Parse)); - parsers.Put(typeof(ushort), SafeParse(ushort.Parse)); - parsers.Put(typeof(ushort?), SafeParse(ushort.Parse)); - parsers.Put(typeof(int), SafeParse(int.Parse)); - parsers.Put(typeof(int?), SafeParse(int.Parse)); - parsers.Put(typeof(uint), SafeParse(uint.Parse)); - parsers.Put(typeof(uint?), SafeParse(uint.Parse)); - parsers.Put(typeof(long), SafeParse(long.Parse)); - parsers.Put(typeof(long?), SafeParse(long.Parse)); - parsers.Put(typeof(ulong), SafeParse(ulong.Parse)); - parsers.Put(typeof(ulong?), SafeParse(ulong.Parse)); - parsers.Put(typeof(float), SafeParse(float.Parse)); - parsers.Put(typeof(float?), SafeParse(float.Parse)); - parsers.Put(typeof(double), SafeParse(double.Parse)); - parsers.Put(typeof(double?), SafeParse(double.Parse)); - parsers.Put(typeof(decimal), SafeParse(decimal.Parse)); - parsers.Put(typeof(decimal?), SafeParse(decimal.Parse)); - parsers.Put(typeof(DateTime), SafeParse(DateTime.Parse)); - parsers.Put(typeof(DateTime?), SafeParse(DateTime.Parse)); - parsers.Put(typeof(TimeSpan), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(TimeSpan?), SafeParse(TimeSpan.Parse)); - parsers.Put(typeof(ZonedDateTime), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(ZonedDateTime?), SafeParse(ParseZonedDateTime)); - parsers.Put(typeof(LocalDate), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalDate?), SafeParse(ParseLocalDate)); - parsers.Put(typeof(LocalTime), SafeParse(ParseLocalTime)); - parsers.Put(typeof(LocalTime?), SafeParse(ParseLocalTime)); - - parsers.Put(typeof(IEnumerable<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(ICollection<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(IList<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(List<string>), ListParse(value => value)); - parsers.Put(typeof(ISet<string>), ImmutableListParse(value => value)); - parsers.Put(typeof(HashSet<string>), SetParse(value => value)); - - parsers.Put(typeof(IEnumerable<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(ICollection<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(IList<bool?>), NullableImmutableListParse(bool.Parse)); - parsers.Put(typeof(List<bool?>), NullableListParse(bool.Parse)); - parsers.Put(typeof(ISet<bool?>), NullableImmutableSetParse(bool.Parse)); - parsers.Put(typeof(HashSet<bool?>), NullableSetParse(bool.Parse)); - - parsers.Put(typeof(IEnumerable<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(ICollection<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(IList<byte>), ImmutableListParse(byte.Parse)); - parsers.Put(typeof(List<byte>), ListParse(byte.Parse)); - parsers.Put(typeof(ISet<byte>), ImmutableSetParse(byte.Parse)); - parsers.Put(typeof(HashSet<byte>), SetParse(byte.Parse)); - - parsers.Put(typeof(IEnumerable<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(ICollection<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(IList<sbyte>), ImmutableListParse(sbyte.Parse)); - parsers.Put(typeof(List<sbyte>), ListParse(sbyte.Parse)); - parsers.Put(typeof(ISet<sbyte>), ImmutableSetParse(sbyte.Parse)); - parsers.Put(typeof(HashSet<sbyte>), SetParse(sbyte.Parse)); - - parsers.Put(typeof(IEnumerable<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(ICollection<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(IList<short>), ImmutableListParse(short.Parse)); - parsers.Put(typeof(List<short>), ListParse(short.Parse)); - parsers.Put(typeof(ISet<short>), ImmutableSetParse(short.Parse)); - parsers.Put(typeof(HashSet<short>), SetParse(short.Parse)); - - parsers.Put(typeof(IEnumerable<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(ICollection<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(IList<ushort>), ImmutableListParse(ushort.Parse)); - parsers.Put(typeof(List<ushort>), ListParse(ushort.Parse)); - parsers.Put(typeof(ISet<ushort>), ImmutableSetParse(ushort.Parse)); - parsers.Put(typeof(HashSet<ushort>), SetParse(ushort.Parse)); - - parsers.Put(typeof(IEnumerable<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(ICollection<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(IList<int?>), NullableImmutableListParse(int.Parse)); - parsers.Put(typeof(List<int?>), NullableListParse(int.Parse)); - parsers.Put(typeof(ISet<int?>), NullableImmutableSetParse(int.Parse)); - parsers.Put(typeof(HashSet<int?>), NullableSetParse(int.Parse)); - - parsers.Put(typeof(IEnumerable<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(ICollection<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(IList<uint>), ImmutableListParse(uint.Parse)); - parsers.Put(typeof(List<uint>), ListParse(uint.Parse)); - parsers.Put(typeof(ISet<uint>), ImmutableSetParse(uint.Parse)); - parsers.Put(typeof(HashSet<uint>), SetParse(uint.Parse)); - - parsers.Put(typeof(IEnumerable<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(ICollection<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(IList<long?>), NullableImmutableListParse(long.Parse)); - parsers.Put(typeof(List<long?>), NullableListParse(long.Parse)); - parsers.Put(typeof(ISet<long?>), NullableImmutableSetParse(long.Parse)); - parsers.Put(typeof(HashSet<long?>), NullableSetParse(long.Parse)); - - parsers.Put(typeof(IEnumerable<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(ICollection<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(IList<ulong>), ImmutableListParse(ulong.Parse)); - parsers.Put(typeof(List<ulong>), ListParse(ulong.Parse)); - parsers.Put(typeof(ISet<ulong>), ImmutableSetParse(ulong.Parse)); - parsers.Put(typeof(HashSet<ulong>), SetParse(ulong.Parse)); - - parsers.Put(typeof(IEnumerable<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(ICollection<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(IList<float?>), NullableImmutableListParse(float.Parse)); - parsers.Put(typeof(List<float?>), NullableListParse(float.Parse)); - parsers.Put(typeof(ISet<float?>), NullableImmutableSetParse(float.Parse)); - parsers.Put(typeof(HashSet<float?>), NullableSetParse(float.Parse)); - - parsers.Put(typeof(IEnumerable<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(ICollection<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(IList<double?>), NullableImmutableListParse(double.Parse)); - parsers.Put(typeof(List<double?>), NullableListParse(double.Parse)); - parsers.Put(typeof(ISet<double?>), NullableImmutableSetParse(double.Parse)); - parsers.Put(typeof(HashSet<double?>), NullableSetParse(double.Parse)); - - parsers.Put(typeof(IEnumerable<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(ICollection<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(IList<decimal?>), NullableImmutableListParse(decimal.Parse)); - parsers.Put(typeof(List<decimal?>), NullableListParse(decimal.Parse)); - parsers.Put(typeof(ISet<decimal?>), NullableImmutableSetParse(decimal.Parse)); - parsers.Put(typeof(HashSet<decimal?>), NullableSetParse(decimal.Parse)); - - parsers.Put(typeof(IEnumerable<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(ICollection<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(IList<DateTime?>), NullableImmutableListParse(DateTime.Parse)); - parsers.Put(typeof(List<DateTime?>), NullableListParse(DateTime.Parse)); - parsers.Put(typeof(ISet<DateTime?>), NullableImmutableSetParse(DateTime.Parse)); - parsers.Put(typeof(HashSet<DateTime?>), NullableSetParse(DateTime.Parse)); - - parsers.Put(typeof(IEnumerable<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(ICollection<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(IList<TimeSpan>), ImmutableListParse(TimeSpan.Parse)); - parsers.Put(typeof(List<TimeSpan>), ListParse(TimeSpan.Parse)); - parsers.Put(typeof(ISet<TimeSpan>), ImmutableSetParse(TimeSpan.Parse)); - parsers.Put(typeof(HashSet<TimeSpan>), SetParse(TimeSpan.Parse)); - - return parsers.ToImmutableDictionary(); - } - - private static Func<Parameter, object> SafeParse<T>(Func<string, T> parse) - { - return parameter => - { - try - { - return parse(parameter.Value); - } - catch (OverflowException) - { - throw ParameterOutOfRange(parameter, typeof(T)); - } - catch (FormatException) - { - throw InvalidParameterFormat(parameter, typeof(T)); - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse parameter: '{0}' with value: '{1}' to {2}", - parameter.Name, parameter.Value, typeof(T)), e); - } - }; - } - - private static Func<Parameter, object> NullableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new List<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToList(); - }; - } - - private static Func<Parameter, object> NullableImmutableListParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableListParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableListParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Lists.EmptyList<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableList(); - }; - } - - private static Func<Parameter, object> NullableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return SetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> SetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return new HashSet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToSet(); - }; - } - - private static Func<Parameter, object> NullableImmutableSetParse<T>(Func<string, T> itemParser) where T: struct - { - return ImmutableSetParse(it => it.ToNullable(itemParser)); - } - - private static Func<Parameter, object> ImmutableSetParse<T>(Func<string, T> itemParser) - { - return parameter => - { - if (string.IsNullOrEmpty(parameter.Value)) - { - return Sets.EmptySet<T>(); - } - return ParseCollection(parameter.Value, itemParser).ToImmutableHashSet(); - }; - } - - private static ZonedDateTime ParseZonedDateTime(string value) - { - var dateTime = DateTime.Parse(value); - return new ZonedDateTime(Instant.FromDateTimeUtc(dateTime.ToUniversalTime()), DateTimeZone.Utc); - } - - private static LocalDate ParseLocalDate(string value) - { - return LocalDatePattern.IsoPattern.Parse(value).Value; - } - - private static LocalTime ParseLocalTime(string value) - { - return LocalTimePattern.ExtendedIsoPattern.Parse(value).Value; - } - - private static ArgumentException ParameterOutOfRange(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query: '{0}' value: '{1}' is out of range for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static ArgumentException InvalidParameterFormat(Parameter parameter, Type type) - { - return new ArgumentException(Strings.Format("Query '{0}' value: '{1}' format is invalid for: '{2}'", - parameter.Name, parameter.Value, type)); - } - - private static IEnumerable<T> ParseCollection<T>(string value, Func<string, T> itemParser) - { - var results = value.Split(new[] { ',' }, StringSplitOptions.None) - .Where(it => it != null) - .Select(it => it.Trim()) - .Select(itemParser); - return results; - } - - public static T? ToNullable<T>(this string s, Func<string, T> itemParser) where T : struct - { - T? result = new T?(); - try - { - if (!string.IsNullOrEmpty(s) && s.Trim().Length > 0) - { - result = itemParser(s); - } - } - catch (Exception e) - { - throw new InvalidOperationException(Strings.Format("Unable to parse value: '{0}' to nullable: '{1}'", s, typeof(T).ToString()), e); - } - return result; - } - - private class Parameter - { - internal string Name { get; private set; } - internal string Value { get; private set; } - - private Parameter(string name, string value) - { - Name = name; - Value = value; - } - - internal static Parameter Of(string name, string value) - { - return new Parameter(name, value); - } - } - } - - internal enum ParameterType - { - Undefined, - Query, - Path, - Header - } -} diff --git a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/packages.config b/samples/server/petstore/nancyfx/src/Org.OpenAPITools/packages.config deleted file mode 100644 index e3401566e5d..00000000000 --- a/samples/server/petstore/nancyfx/src/Org.OpenAPITools/packages.config +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="Nancy" version="1.4.3" targetFramework="net45" /> - <package id="NodaTime" version="1.3.1" targetFramework="net45" /> - <package id="Sharpility" version="1.2.2" targetFramework="net45" /> - <package id="System.Collections.Immutable" version="1.1.37" targetFramework="net45" /> -</packages> \ No newline at end of file diff --git a/website/i18n/en.json b/website/i18n/en.json index 5011d1b3c55..6f753f00ded 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -115,10 +115,6 @@ "title": "Config Options for csharp-dotnet2", "sidebar_label": "csharp-dotnet2" }, - "generators/csharp-nancyfx": { - "title": "Config Options for csharp-nancyfx", - "sidebar_label": "csharp-nancyfx" - }, "generators/csharp-netcore": { "title": "Config Options for csharp-netcore", "sidebar_label": "csharp-netcore" -- GitLab From 659455ed8a5e8fcf1dd06fedface3045e9395db6 Mon Sep 17 00:00:00 2001 From: devhl <shawnkanyer@gmail.com> Date: Fri, 28 Jan 2022 20:50:14 -0500 Subject: [PATCH 2/3] didnt save one file --- docs/migration-from-swagger-codegen.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/migration-from-swagger-codegen.md b/docs/migration-from-swagger-codegen.md index f4bd36b6d33..85232ebb91b 100644 --- a/docs/migration-from-swagger-codegen.md +++ b/docs/migration-from-swagger-codegen.md @@ -130,7 +130,6 @@ All languages of `swagger-codegen` have been migrated to `openapi-generator`, bu | `lumen` | `php-lumen` | | `slim` | `php-slim` | | `ze-ph` | `php-mezzio-ph` | -| `nancyfx` | `csharp-nancyfx` | We provide a temporary mapping in code for these old values. You'll receive a warning with instructions to migrate to the new names. -- GitLab From 356b753d54e50fa2dd73641b3a9e7a066a79019b Mon Sep 17 00:00:00 2001 From: devhl <shawnkanyer@gmail.com> Date: Sat, 5 Feb 2022 14:40:23 -0500 Subject: [PATCH 3/3] removed two more nancyfx files --- docs/generators/csharp-nancyfx-deprecated.md | 209 --------- .../languages/CSharpNancyFXServerCodegen.java | 441 ------------------ 2 files changed, 650 deletions(-) delete mode 100644 docs/generators/csharp-nancyfx-deprecated.md delete mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java diff --git a/docs/generators/csharp-nancyfx-deprecated.md b/docs/generators/csharp-nancyfx-deprecated.md deleted file mode 100644 index 519edc27307..00000000000 --- a/docs/generators/csharp-nancyfx-deprecated.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -title: Documentation for the csharp-nancyfx-deprecated Generator ---- - -## METADATA - -| Property | Value | Notes | -| -------- | ----- | ----- | -| generator name | csharp-nancyfx-deprecated | pass this to the generate command after -g | -| generator stability | DEPRECATED | | -| generator type | SERVER | | -| generator language | C# | | -| generator default templating engine | mustache | | -| helpTxt | Generates a C# NancyFX Web API server (deprecated). | | - -## CONFIG OPTIONS -These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. - -| Option | Description | Values | Default | -| ------ | ----------- | ------ | ------- | -|asyncServer|Set to true to enable the generation of async routes/endpoints.| |false| -|immutable|Enabled by default. If disabled generates model classes with setters| |true| -|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| || -|optionalProjectFile|Generate {PackageName}.csproj.| |true| -|packageContext|Optionally overrides the PackageContext which determines the namespace (namespace=packageName.packageContext). If not set, packageContext will default to basePath.| |null| -|packageGuid|The GUID that will be associated with the C# project| |null| -|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools| -|packageVersion|C# package version.| |1.0.0| -|returnICollection|Return ICollection<T> instead of the concrete type.| |false| -|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| -|sourceFolder|source folder for generated code| |src| -|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false| -|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false| -|writeModulePath|Enabled by default. If disabled, module paths will not mirror api base path| |true| - -## IMPORT MAPPING - -| Type/Alias | Imports | -| ---------- | ------- | - - -## INSTANTIATION TYPES - -| Type/Alias | Instantiated By | -| ---------- | --------------- | -|array|List| -|list|List| -|map|Dictionary| - - -## LANGUAGE PRIMITIVES - -<ul class="column-ul"> -<li>Boolean</li> -<li>Collection</li> -<li>DateTime</li> -<li>DateTime?</li> -<li>DateTimeOffset</li> -<li>DateTimeOffset?</li> -<li>Decimal</li> -<li>Dictionary</li> -<li>Double</li> -<li>Float</li> -<li>Guid</li> -<li>Guid?</li> -<li>ICollection</li> -<li>Int32</li> -<li>Int64</li> -<li>List</li> -<li>LocalDate?</li> -<li>LocalTime?</li> -<li>Object</li> -<li>String</li> -<li>System.IO.Stream</li> -<li>ZonedDateTime?</li> -<li>bool</li> -<li>bool?</li> -<li>byte[]</li> -<li>decimal</li> -<li>decimal?</li> -<li>double</li> -<li>double?</li> -<li>float</li> -<li>float?</li> -<li>int</li> -<li>int?</li> -<li>long</li> -<li>long?</li> -<li>string</li> -</ul> - -## RESERVED WORDS - -<ul class="column-ul"> -<li>async</li> -<li>await</li> -<li>dynamic</li> -<li>var</li> -<li>yield</li> -</ul> - -## FEATURE SET - - -### Client Modification Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|BasePath|✗|ToolingExtension -|Authorizations|✗|ToolingExtension -|UserAgent|✗|ToolingExtension -|MockServer|✗|ToolingExtension - -### Data Type Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Custom|✗|OAS2,OAS3 -|Int32|✓|OAS2,OAS3 -|Int64|✓|OAS2,OAS3 -|Float|✓|OAS2,OAS3 -|Double|✓|OAS2,OAS3 -|Decimal|✓|ToolingExtension -|String|✓|OAS2,OAS3 -|Byte|✓|OAS2,OAS3 -|Binary|✓|OAS2,OAS3 -|Boolean|✓|OAS2,OAS3 -|Date|✓|OAS2,OAS3 -|DateTime|✓|OAS2,OAS3 -|Password|✓|OAS2,OAS3 -|File|✓|OAS2 -|Array|✓|OAS2,OAS3 -|Maps|✓|ToolingExtension -|CollectionFormat|✓|OAS2 -|CollectionFormatMulti|✓|OAS2 -|Enum|✓|OAS2,OAS3 -|ArrayOfEnum|✓|ToolingExtension -|ArrayOfModel|✓|ToolingExtension -|ArrayOfCollectionOfPrimitives|✓|ToolingExtension -|ArrayOfCollectionOfModel|✓|ToolingExtension -|ArrayOfCollectionOfEnum|✓|ToolingExtension -|MapOfEnum|✓|ToolingExtension -|MapOfModel|✓|ToolingExtension -|MapOfCollectionOfPrimitives|✓|ToolingExtension -|MapOfCollectionOfModel|✓|ToolingExtension -|MapOfCollectionOfEnum|✓|ToolingExtension - -### Documentation Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Readme|✗|ToolingExtension -|Model|✓|ToolingExtension -|Api|✓|ToolingExtension - -### Global Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Host|✓|OAS2,OAS3 -|BasePath|✓|OAS2,OAS3 -|Info|✓|OAS2,OAS3 -|Schemes|✗|OAS2,OAS3 -|PartialSchemes|✓|OAS2,OAS3 -|Consumes|✓|OAS2 -|Produces|✓|OAS2 -|ExternalDocumentation|✓|OAS2,OAS3 -|Examples|✓|OAS2,OAS3 -|XMLStructureDefinitions|✗|OAS2,OAS3 -|MultiServer|✗|OAS3 -|ParameterizedServer|✗|OAS3 -|ParameterStyling|✗|OAS3 -|Callbacks|✗|OAS3 -|LinkObjects|✗|OAS3 - -### Parameter Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Path|✓|OAS2,OAS3 -|Query|✓|OAS2,OAS3 -|Header|✓|OAS2,OAS3 -|Body|✓|OAS2 -|FormUnencoded|✓|OAS2 -|FormMultipart|✓|OAS2 -|Cookie|✗|OAS3 - -### Schema Support Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|Simple|✓|OAS2,OAS3 -|Composite|✓|OAS2,OAS3 -|Polymorphism|✓|OAS2,OAS3 -|Union|✗|OAS3 - -### Security Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|BasicAuth|✗|OAS2,OAS3 -|ApiKey|✗|OAS2,OAS3 -|OpenIDConnect|✗|OAS3 -|BearerToken|✗|OAS3 -|OAuth2_Implicit|✗|OAS2,OAS3 -|OAuth2_Password|✗|OAS2,OAS3 -|OAuth2_ClientCredentials|✗|OAS2,OAS3 -|OAuth2_AuthorizationCode|✗|OAS2,OAS3 - -### Wire Format Feature -| Name | Supported | Defined By | -| ---- | --------- | ---------- | -|JSON|✓|OAS2,OAS3 -|XML|✓|OAS2,OAS3 -|PROTOBUF|✗|ToolingExtension -|Custom|✗|OAS2,OAS3 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java deleted file mode 100644 index 280d26f7a16..00000000000 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) - * Copyright 2018 SmartBear Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openapitools.codegen.languages; - -import com.google.common.base.Predicate; -import com.google.common.collect.*; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.Schema; -import org.openapitools.codegen.*; -import org.openapitools.codegen.meta.features.*; -import org.openapitools.codegen.meta.GeneratorMetadata; -import org.openapitools.codegen.meta.Stability; -import org.openapitools.codegen.utils.ModelUtils; -import org.openapitools.codegen.utils.URLPathUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.net.URL; -import java.util.*; -import java.util.Map.Entry; - -import static com.google.common.base.Strings.isNullOrEmpty; -import static java.util.Arrays.asList; -import static java.util.UUID.randomUUID; -import static org.apache.commons.lang3.StringUtils.capitalize; -import static org.openapitools.codegen.CodegenConstants.*; -import static org.openapitools.codegen.CodegenType.SERVER; -import static org.openapitools.codegen.utils.StringUtils.camelize; - -public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen { - private final Logger LOGGER = LoggerFactory.getLogger(CSharpNancyFXServerCodegen.class); - - private static final String API_NAMESPACE = "Modules"; - private static final String MODEL_NAMESPACE = "Models"; - private static final String IMMUTABLE_OPTION = "immutable"; - private static final String USE_BASE_PATH = "writeModulePath"; - private static final String PACKAGE_CONTEXT = "packageContext"; - private static final String ASYNC_SERVER = "asyncServer"; - - private static final Map<String, Predicate<Schema>> propertyToOpenAPITypeMapping = - createPropertyToOpenAPITypeMapping(); - - private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}"; - - private final Map<String, DependencyInfo> dependencies = new HashMap<>(); - private final Set<String> parentModels = new HashSet<>(); - private final Multimap<String, CodegenModel> childrenByParent = ArrayListMultimap.create(); - private final BiMap<String, String> modelNameMapping = HashBiMap.create(); - - /** - * If set to true, we will generate c# async endpoints and service interfaces - */ - private boolean asyncServer = false; - - public CSharpNancyFXServerCodegen() { - super(); - - modifyFeatureSet(features -> features - .excludeDocumentationFeatures(DocumentationFeature.Readme) - .securityFeatures(EnumSet.noneOf(SecurityFeature.class)) - .excludeGlobalFeatures( - GlobalFeature.XMLStructureDefinitions, - GlobalFeature.Callbacks, - GlobalFeature.LinkObjects, - GlobalFeature.ParameterStyling - ) - .includeSchemaSupportFeatures( - SchemaSupportFeature.Polymorphism - ) - .excludeParameterFeatures( - ParameterFeature.Cookie - ) - ); - - generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) - .stability(Stability.DEPRECATED) - .build(); - - outputFolder = "generated-code" + File.separator + getName(); - apiTemplateFiles.put("api.mustache", ".cs"); - - // Early versions use no prefix for interfaces. Defaulting to I- common practice would break existing users. - setInterfacePrefix(""); - - // contextually reserved words - setReservedWordsLowerCase( - asList("var", "async", "await", "dynamic", "yield") - ); - - cliOptions.clear(); - - // CLI options - addOption(PACKAGE_NAME, "C# package name (convention: Title.Case).", packageName); - addOption(PACKAGE_VERSION, "C# package version.", packageVersion); - addOption(SOURCE_FOLDER, SOURCE_FOLDER_DESC, sourceFolder); - addOption(INTERFACE_PREFIX, INTERFACE_PREFIX_DESC, interfacePrefix); - addOption(OPTIONAL_PROJECT_GUID, OPTIONAL_PROJECT_GUID_DESC, null); - addOption(PACKAGE_CONTEXT, "Optionally overrides the PackageContext which determines the namespace (namespace=packageName.packageContext). If not set, packageContext will default to basePath.", null); - - // CLI Switches - addSwitch(SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_BY_REQUIRED_FLAG_DESC, sortParamsByRequiredFlag); - addSwitch(OPTIONAL_PROJECT_FILE, OPTIONAL_PROJECT_FILE_DESC, optionalProjectFileFlag); - addSwitch(USE_DATETIME_OFFSET, USE_DATETIME_OFFSET_DESC, useDateTimeOffsetFlag); - addSwitch(USE_COLLECTION, USE_COLLECTION_DESC, useCollection); - addSwitch(RETURN_ICOLLECTION, RETURN_ICOLLECTION_DESC, returnICollection); - addSwitch(IMMUTABLE_OPTION, "Enabled by default. If disabled generates model classes with setters", true); - addSwitch(USE_BASE_PATH, "Enabled by default. If disabled, module paths will not mirror api base path", true); - addSwitch(ASYNC_SERVER, "Set to true to enable the generation of async routes/endpoints.", this.asyncServer); - typeMapping.putAll(nodaTimeTypesMappings()); - languageSpecificPrimitives.addAll(nodaTimePrimitiveTypes()); - } - - @Override - public CodegenType getTag() { - return SERVER; - } - - @Override - public String getName() { - return "csharp-nancyfx-deprecated"; - } - - @Override - public String getHelp() { - return "Generates a C# NancyFX Web API server (deprecated)."; - } - - @Override - public void processOpts() { - super.processOpts(); - - apiPackage = isNullOrEmpty(packageName) ? API_NAMESPACE : packageName + "." + API_NAMESPACE; - modelPackage = isNullOrEmpty(packageName) ? MODEL_NAMESPACE : packageName + "." + MODEL_NAMESPACE; - - supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); - supportingFiles.add(new SupportingFile("parameters.mustache", sourceFile("Utils"), "Parameters.cs")); - supportingFiles.add(new SupportingFile("localDateConverter.mustache", sourceFile("Utils"), "LocalDateConverter.cs")); - supportingFiles.add(new SupportingFile("packages.config.mustache", sourceFolder(), "packages.config")); - supportingFiles.add(new SupportingFile("nuspec.mustache", sourceFolder(), packageName + ".nuspec")); - - if (optionalProjectFileFlag) { - supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln")); - supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder(), packageName + ".csproj")); - } - - if (additionalProperties.containsKey(OPTIONAL_PROJECT_GUID)) { - setPackageGuid((String) additionalProperties.get(OPTIONAL_PROJECT_GUID)); - } - - if (additionalProperties.containsKey(ASYNC_SERVER)) { - setAsyncServer(convertPropertyToBooleanAndWriteBack(ASYNC_SERVER)); - } else { - additionalProperties.put(ASYNC_SERVER, this.asyncServer); - } - - additionalProperties.put("packageGuid", packageGuid); - - setupModelTemplate(); - processImportedMappings(); - appendDependencies(); - } - - private void setupModelTemplate() { - final Object immutableOption = additionalProperties.get(IMMUTABLE_OPTION); - if (immutableOption != null && "false".equalsIgnoreCase(immutableOption.toString())) { - LOGGER.info("Using mutable model template"); - modelTemplateFiles.put("modelMutable.mustache", ".cs"); - } else { - LOGGER.info("Using immutable model template"); - modelTemplateFiles.put("model.mustache", ".cs"); - } - } - - private void processImportedMappings() { - for (final Entry<String, String> entry : ImmutableSet.copyOf(importMapping.entrySet())) { - final String model = entry.getKey(); - final String[] namespaceInfo = entry.getValue().split("\\s"); - final String[] namespace = (namespaceInfo.length > 0 ? namespaceInfo[0].trim() : "").split(":"); - final String namespaceName = namespace.length > 0 ? namespace[0].trim() : null; - final String modelClass = namespace.length > 1 ? namespace[1].trim() : null; - final String assembly = namespaceInfo.length > 1 ? namespaceInfo[1].trim() : null; - final String assemblyVersion = namespaceInfo.length > 2 ? namespaceInfo[2].trim() : null; - final String assemblyFramework = namespaceInfo.length > 3 ? namespaceInfo[3].trim() : "net45"; - - if (isNullOrEmpty(model) || isNullOrEmpty(namespaceName)) { - LOGGER.warn(String.format(Locale.ROOT, "Could not import: '%s' - invalid namespace: '%s'", model, entry.getValue())); - importMapping.remove(model); - } else { - LOGGER.info(String.format(Locale.ROOT, "Importing: '%s' from '%s' namespace.", model, namespaceName)); - importMapping.put(model, namespaceName); - } - if (!isNullOrEmpty(modelClass)) { - LOGGER.info(String.format(Locale.ROOT, "Mapping: '%s' class to '%s'", model, modelClass)); - modelNameMapping.put(model, modelClass); - } - if (assembly != null && assemblyVersion != null) { - LOGGER.info(String.format(Locale.ROOT, "Adding dependency: '%s', version: '%s', framework: '%s'", - assembly, assemblyVersion, assemblyVersion)); - dependencies.put(assembly, new DependencyInfo(assemblyVersion, assemblyFramework)); - } - } - } - - private void appendDependencies() { - final List<Map<String, String>> listOfDependencies = new ArrayList<>(); - for (final Entry<String, DependencyInfo> dependency : dependencies.entrySet()) { - final Map<String, String> dependencyInfo = new HashMap<>(); - dependencyInfo.put("dependency", dependency.getKey()); - dependencyInfo.put("dependencyVersion", dependency.getValue().version); - dependencyInfo.put("dependencyFramework", dependency.getValue().framework); - listOfDependencies.add(dependencyInfo); - } - additionalProperties.put("dependencies", listOfDependencies); - } - - private String sourceFolder() { - return "src" + File.separator + packageName; - } - - private String sourceFile(final String fileName) { - return sourceFolder() + File.separator + fileName; - } - - public void setPackageGuid(String packageGuid) { - this.packageGuid = packageGuid; - } - - public void setAsyncServer(boolean asyncServer) { - this.asyncServer = asyncServer; - } - - @Override - public String apiFileFolder() { - return outputFolder + File.separator + sourceFolder() + File.separator + API_NAMESPACE; - } - - @Override - public String modelFileFolder() { - return outputFolder + File.separator + sourceFolder() + File.separator + MODEL_NAMESPACE; - } - - @Override - protected void processOperation(final CodegenOperation operation) { - super.processOperation(operation); - if (!isNullOrEmpty(operation.path) && operation.path.contains("?")) { - operation.path = operation.path.replace("?", "/"); - } - if (!isNullOrEmpty(operation.httpMethod)) { - operation.httpMethod = capitalize(operation.httpMethod.toLowerCase(Locale.ROOT)); - } - } - - @Override - public Map<String, Object> postProcessAllModels(final Map<String, Object> models) { - final Map<String, Object> processed = super.postProcessAllModels(models); - postProcessParentModels(models); - return processed; - } - - private void postProcessParentModels(final Map<String, Object> models) { - LOGGER.debug("Processing parents: {}", parentModels); - for (final String parent : parentModels) { - final CodegenModel parentModel = ModelUtils.getModelByName(parent, models); - if (parentModel != null) { - parentModel.hasChildren = true; - final Collection<CodegenModel> childrenModels = childrenByParent.get(parent); - for (final CodegenModel child : childrenModels) { - processParentPropertiesInChildModel(parentModel, child); - } - } - } - } - - private void processParentPropertiesInChildModel(final CodegenModel parent, final CodegenModel child) { - final Map<String, CodegenProperty> childPropertiesByName = new HashMap<>(child.vars.size()); - for (final CodegenProperty property : child.vars) { - childPropertiesByName.put(property.name, property); - } - CodegenProperty previousParentVar = null; - for (final CodegenProperty property : parent.vars) { - final CodegenProperty duplicatedByParent = childPropertiesByName.get(property.name); - if (duplicatedByParent != null) { - LOGGER.info(String.format(Locale.ROOT, "Property: '%s' in '%s' model is inherited from '%s'", - property.name, child.classname, parent.classname)); - duplicatedByParent.isInherited = true; - final CodegenProperty parentVar = duplicatedByParent.clone(); - child.parentVars.add(parentVar); - previousParentVar = parentVar; - } - } - } - - @Override - public void postProcessModelProperty(final CodegenModel model, final CodegenProperty property) { - super.postProcessModelProperty(model, property); - if (!isNullOrEmpty(model.parent)) { - parentModels.add(model.parent); - if (!childrenByParent.containsEntry(model.parent, model)) { - childrenByParent.put(model.parent, model); - } - } - } - - @Override - public String toEnumVarName(final String name, final String datatype) { - if (name.length() == 0) { - return "Empty"; - } - - final String enumName = camelize( - sanitizeName(name) - .replaceFirst("^_", "") - .replaceFirst("_$", "") - .replaceAll("-", "_")); - final String result; - if (enumName.matches("\\d.*")) { - result = "_" + enumName; - } else { - result = enumName; - } - LOGGER.debug(String.format(Locale.ROOT, "toEnumVarName('%s', %s) = '%s'", name, datatype, enumName)); - return result; - } - - @Override - public String toApiName(final String name) { - final String apiName; - if (isNullOrEmpty(name)) { - apiName = "Default"; - } else { - apiName = capitalize(name); - } - LOGGER.debug(String.format(Locale.ROOT, "toApiName('%s') = '%s'", name, apiName)); - return apiName; - } - - @Override - public String toApiFilename(final String name) { - return super.toApiFilename(name) + "Module"; - } - - @Override - public String toModelImport(final String name) { - final String result; - if (modelNameMapping.containsValue(name)) { - final String modelName = modelNameMapping.inverse().get(name); - result = importMapping.containsKey(modelName) ? - importMapping.get(modelName) : super.toModelImport(name); - } else if (importMapping.containsKey(name)) { - result = importMapping.get(name); - } else { - result = null; - } - LOGGER.debug(String.format(Locale.ROOT, "toModelImport('%s') = '%s'", name, result)); - return result; - } - - @Override - public String toModelName(final String name) { - final String modelName = super.toModelName(name); - final String mappedModelName = modelNameMapping.get(modelName); - return isNullOrEmpty(mappedModelName) ? modelName : mappedModelName; - } - - @Override - public void preprocessOpenAPI(final OpenAPI openAPI) { - URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides()); - String path = URLPathUtils.getPath(url, "/"); - final String packageContextOption = (String) additionalProperties.get(PACKAGE_CONTEXT); - additionalProperties.put("packageContext", packageContextOption == null ? sanitizeName(path) : packageContextOption); - final Object basePathOption = additionalProperties.get(USE_BASE_PATH); - additionalProperties.put("baseContext", basePathOption == null ? path : "/"); - } - - @Override - public String toEnumName(final CodegenProperty property) { - return sanitizeName(camelize(property.name)) + "Enum"; - } - - @Override - public String getSchemaType(final Schema property) { - for (Entry<String, Predicate<Schema>> entry : propertyToOpenAPITypeMapping.entrySet()) { - if (entry.getValue().apply(property)) { - return entry.getKey(); - } - } - return super.getSchemaType(property); - } - - private static Map<String, Predicate<Schema>> createPropertyToOpenAPITypeMapping() { - final ImmutableMap.Builder<String, Predicate<Schema>> mapping = ImmutableMap.builder(); - mapping.put("time", timeProperty()); - return mapping.build(); - } - - private static Predicate<Schema> timeProperty() { - return new Predicate<Schema>() { - @Override - public boolean apply(Schema property) { - return ModelUtils.isStringSchema(property) && "time".equalsIgnoreCase(property.getFormat()); - } - }; - } - - private static Map<String, String> nodaTimeTypesMappings() { - return ImmutableMap.of( - "time", "LocalTime?", - "date", "LocalDate?", - "datetime", "ZonedDateTime?"); - } - - private static Set<String> nodaTimePrimitiveTypes() { - return ImmutableSet.of("LocalTime?", "LocalDate?", "ZonedDateTime?"); - } - - private static class DependencyInfo { - private final String version; - private final String framework; - - private DependencyInfo(final String version, final String framework) { - this.version = version; - this.framework = framework; - } - } -} -- GitLab