From 0002f8c5064dde941afb761e2b103a53f40d59f8 Mon Sep 17 00:00:00 2001 From: Liri S Date: Tue, 16 Jul 2024 19:02:41 +0300 Subject: [PATCH] Support net8 in aspnetcore (#19051) * Support net8 in aspnetcore * gen * typo * more * default swashbuckle * gen --------- Co-authored-by: Liri S --- .github/workflows/samples-dotnet8-server.yaml | 36 + .../aspnetcore-8.0-NewtonsoftFalse.yaml | 9 + ...aspnetcore-8.0-nullableReferenceTypes.yaml | 9 + bin/configs/aspnetcore-8.0-pocoModels.yaml | 9 + .../aspnetcore-8.0-project4Models.yaml | 9 + .../aspnetcore-8.0-useSwashBuckle.yaml | 11 + bin/configs/aspnetcore-8.0.yaml | 8 + docs/generators/aspnetcore.md | 4 +- .../languages/AspNetServerCodegen.java | 12 +- .../typescript-axios/build/package.json | 2 +- samples/client/petstore/k6/script.js | 242 +--- .../builds/es6-target/package.json | 2 +- .../package.json | 2 +- .../builds/with-npm-version/package.json | 2 +- .../default-v3.0/models/AllOfWithSingleRef.ts | 2 - .../models/OuterObjectWithEnumProperty.ts | 2 - .../builds/enum/models/EnumPatternObject.ts | 2 - .../src/models/GetBehaviorTypeResponse.ts | 2 - .../src/models/GetPetPartTypeResponse.ts | 2 - .../models/AllOfWithSingleRef.ts | 2 - .../models/OuterObjectWithEnumProperty.ts | 2 - .../models/EnumPatternObject.ts | 2 - .../server/petstore/aspnetcore-3.1/README.md | 2 +- .../src/Org.OpenAPITools/Dockerfile | 4 +- .../src/Org.OpenAPITools/Startup.cs | 2 +- .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 38 + .../.openapi-generator/VERSION | 1 + .../Org.OpenAPITools.sln | 22 + .../aspnetcore-8.0-NewtonsoftFalse/README.md | 50 + .../aspnetcore-8.0-NewtonsoftFalse/build.bat | 9 + .../aspnetcore-8.0-NewtonsoftFalse/build.sh | 8 + .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 49 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 73 + .../Org.OpenAPITools/Controllers/PetApi.cs | 260 ++++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 141 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 218 +++ .../Converters/CustomEnumConverter.cs | 52 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Formatters/InputFormatterStream.cs | 45 + .../src/Org.OpenAPITools/Models/Animal.cs | 146 ++ .../Org.OpenAPITools/Models/ApiResponse.cs | 152 +++ .../src/Org.OpenAPITools/Models/Cat.cs | 124 ++ .../src/Org.OpenAPITools/Models/Category.cs | 139 ++ .../src/Org.OpenAPITools/Models/Dog.cs | 124 ++ .../src/Org.OpenAPITools/Models/Order.cs | 223 +++ .../src/Org.OpenAPITools/Models/Pet.cs | 228 ++++ .../src/Org.OpenAPITools/Models/Tag.cs | 138 ++ .../src/Org.OpenAPITools/Models/TestEnum.cs | 42 + .../Org.OpenAPITools/Models/TestNullable.cs | 138 ++ .../src/Org.OpenAPITools/Models/User.cs | 223 +++ .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 26 + .../src/Org.OpenAPITools/Program.cs | 33 + .../Properties/launchSettings.json | 37 + .../src/Org.OpenAPITools/Startup.cs | 150 ++ .../appsettings.Development.json | 9 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/wwwroot/README.md | 42 + .../src/Org.OpenAPITools/wwwroot/index.html | 1 + .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 38 + .../.openapi-generator/VERSION | 1 + .../Org.OpenAPITools.sln | 22 + .../README.md | 50 + .../build.bat | 9 + .../build.sh | 8 + .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 49 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 73 + .../Org.OpenAPITools/Controllers/PetApi.cs | 260 ++++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 141 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 218 +++ .../Converters/CustomEnumConverter.cs | 52 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Formatters/InputFormatterStream.cs | 45 + .../src/Org.OpenAPITools/Models/Animal.cs | 142 ++ .../Org.OpenAPITools/Models/ApiResponse.cs | 147 ++ .../src/Org.OpenAPITools/Models/Cat.cs | 119 ++ .../src/Org.OpenAPITools/Models/Category.cs | 134 ++ .../src/Org.OpenAPITools/Models/Dog.cs | 119 ++ .../src/Org.OpenAPITools/Models/Order.cs | 219 +++ .../src/Org.OpenAPITools/Models/Pet.cs | 224 +++ .../src/Org.OpenAPITools/Models/Tag.cs | 133 ++ .../src/Org.OpenAPITools/Models/TestEnum.cs | 43 + .../Org.OpenAPITools/Models/TestNullable.cs | 133 ++ .../src/Org.OpenAPITools/Models/User.cs | 218 +++ .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 28 + .../src/Org.OpenAPITools/Program.cs | 33 + .../Properties/launchSettings.json | 37 + .../src/Org.OpenAPITools/Startup.cs | 155 +++ .../appsettings.Development.json | 9 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/wwwroot/README.md | 42 + .../src/Org.OpenAPITools/wwwroot/index.html | 1 + .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 38 + .../.openapi-generator/VERSION | 1 + .../Org.OpenAPITools.sln | 22 + .../aspnetcore-8.0-pocoModels/README.md | 50 + .../aspnetcore-8.0-pocoModels/build.bat | 9 + .../aspnetcore-8.0-pocoModels/build.sh | 8 + .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 49 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 73 + .../Org.OpenAPITools/Controllers/PetApi.cs | 260 ++++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 141 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 218 +++ .../Converters/CustomEnumConverter.cs | 52 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Formatters/InputFormatterStream.cs | 45 + .../src/Org.OpenAPITools/Models/Animal.cs | 51 + .../Org.OpenAPITools/Models/ApiResponse.cs | 48 + .../src/Org.OpenAPITools/Models/Cat.cs | 36 + .../src/Org.OpenAPITools/Models/Category.cs | 43 + .../src/Org.OpenAPITools/Models/Dog.cs | 36 + .../src/Org.OpenAPITools/Models/Order.cs | 96 ++ .../src/Org.OpenAPITools/Models/Pet.cs | 99 ++ .../src/Org.OpenAPITools/Models/Tag.cs | 42 + .../src/Org.OpenAPITools/Models/TestEnum.cs | 43 + .../Org.OpenAPITools/Models/TestNullable.cs | 42 + .../src/Org.OpenAPITools/Models/User.cs | 79 ++ .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 27 + .../src/Org.OpenAPITools/Program.cs | 33 + .../Properties/launchSettings.json | 37 + .../src/Org.OpenAPITools/Startup.cs | 155 +++ .../appsettings.Development.json | 9 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/wwwroot/README.md | 42 + .../src/Org.OpenAPITools/wwwroot/index.html | 1 + .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 40 + .../.openapi-generator/VERSION | 1 + .../Org.OpenAPITools.sln | 28 + .../aspnetcore-8.0-project4Models/README.md | 50 + .../aspnetcore-8.0-project4Models/build.bat | 9 + .../aspnetcore-8.0-project4Models/build.sh | 8 + .../src/Org.OpenAPITools.Models/.gitignore | 362 +++++ .../src/Org.OpenAPITools.Models/Animal.cs | 142 ++ .../Org.OpenAPITools.Models/ApiResponse.cs | 147 ++ .../src/Org.OpenAPITools.Models/Cat.cs | 119 ++ .../src/Org.OpenAPITools.Models/Category.cs | 134 ++ .../Converters/CustomEnumConverter.cs | 52 + .../src/Org.OpenAPITools.Models/Dog.cs | 119 ++ .../src/Org.OpenAPITools.Models/Order.cs | 219 +++ .../Org.OpenAPITools.Models.csproj | 23 + .../src/Org.OpenAPITools.Models/Pet.cs | 224 +++ .../src/Org.OpenAPITools.Models/Tag.cs | 133 ++ .../src/Org.OpenAPITools.Models/TestEnum.cs | 43 + .../Org.OpenAPITools.Models/TestNullable.cs | 133 ++ .../src/Org.OpenAPITools.Models/User.cs | 218 +++ .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 49 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 73 + .../Org.OpenAPITools/Controllers/PetApi.cs | 260 ++++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 141 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 218 +++ .../src/Org.OpenAPITools/Dockerfile | 32 + .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Formatters/InputFormatterStream.cs | 45 + .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 27 + .../src/Org.OpenAPITools/Program.cs | 33 + .../Properties/launchSettings.json | 37 + .../src/Org.OpenAPITools/Startup.cs | 155 +++ .../appsettings.Development.json | 9 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/wwwroot/README.md | 42 + .../src/Org.OpenAPITools/wwwroot/index.html | 1 + .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 28 + .../.openapi-generator/VERSION | 1 + .../Org.OpenAPITools.sln | 22 + .../aspnetcore-8.0-useSwashBuckle/README.md | 43 + .../aspnetcore-8.0-useSwashBuckle/build.bat | 9 + .../aspnetcore-8.0-useSwashBuckle/build.sh | 8 + .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 38 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 48 + .../Org.OpenAPITools/Controllers/PetApi.cs | 136 ++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 79 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 129 ++ .../Converters/CustomEnumConverter.cs | 52 + .../Formatters/InputFormatterStream.cs | 45 + .../src/Org.OpenAPITools/Models/Animal.cs | 138 ++ .../Org.OpenAPITools/Models/ApiResponse.cs | 147 ++ .../src/Org.OpenAPITools/Models/Cat.cs | 119 ++ .../src/Org.OpenAPITools/Models/Category.cs | 134 ++ .../src/Org.OpenAPITools/Models/Dog.cs | 119 ++ .../src/Org.OpenAPITools/Models/Order.cs | 219 +++ .../src/Org.OpenAPITools/Models/Pet.cs | 224 +++ .../src/Org.OpenAPITools/Models/Tag.cs | 133 ++ .../src/Org.OpenAPITools/Models/TestEnum.cs | 43 + .../Org.OpenAPITools/Models/TestNullable.cs | 133 ++ .../src/Org.OpenAPITools/Models/User.cs | 218 +++ .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 26 + .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 20 + .../aspnetcore-8.0/.openapi-generator-ignore | 23 + .../aspnetcore-8.0/.openapi-generator/FILES | 38 + .../aspnetcore-8.0/.openapi-generator/VERSION | 1 + .../aspnetcore-8.0/Org.OpenAPITools.sln | 22 + .../server/petstore/aspnetcore-8.0/README.md | 50 + .../server/petstore/aspnetcore-8.0/build.bat | 9 + .../server/petstore/aspnetcore-8.0/build.sh | 8 + .../src/Org.OpenAPITools/.gitignore | 362 +++++ .../Attributes/ValidateModelStateAttribute.cs | 69 + .../Authentication/ApiAuthentication.cs | 72 + .../Controllers/DefaultApi.cs | 49 + .../Org.OpenAPITools/Controllers/FakeApi.cs | 73 + .../Org.OpenAPITools/Controllers/PetApi.cs | 260 ++++ .../Org.OpenAPITools/Controllers/StoreApi.cs | 141 ++ .../Org.OpenAPITools/Controllers/UserApi.cs | 218 +++ .../Converters/CustomEnumConverter.cs | 52 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Formatters/InputFormatterStream.cs | 45 + .../src/Org.OpenAPITools/Models/Animal.cs | 142 ++ .../Org.OpenAPITools/Models/ApiResponse.cs | 147 ++ .../src/Org.OpenAPITools/Models/Cat.cs | 119 ++ .../src/Org.OpenAPITools/Models/Category.cs | 134 ++ .../src/Org.OpenAPITools/Models/Dog.cs | 119 ++ .../src/Org.OpenAPITools/Models/Order.cs | 219 +++ .../src/Org.OpenAPITools/Models/Pet.cs | 224 +++ .../src/Org.OpenAPITools/Models/Tag.cs | 133 ++ .../src/Org.OpenAPITools/Models/TestEnum.cs | 43 + .../Org.OpenAPITools/Models/TestNullable.cs | 133 ++ .../src/Org.OpenAPITools/Models/User.cs | 218 +++ .../OpenApi/TypeExtensions.cs | 61 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 27 + .../src/Org.OpenAPITools/Program.cs | 33 + .../Properties/launchSettings.json | 37 + .../src/Org.OpenAPITools/Startup.cs | 155 +++ .../appsettings.Development.json | 9 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/wwwroot/README.md | 42 + .../src/Org.OpenAPITools/wwwroot/index.html | 1 + .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../Org.OpenAPITools/Org.OpenAPITools.csproj | 4 +- 264 files changed, 26959 insertions(+), 232 deletions(-) create mode 100644 .github/workflows/samples-dotnet8-server.yaml create mode 100644 bin/configs/aspnetcore-8.0-NewtonsoftFalse.yaml create mode 100644 bin/configs/aspnetcore-8.0-nullableReferenceTypes.yaml create mode 100644 bin/configs/aspnetcore-8.0-pocoModels.yaml create mode 100644 bin/configs/aspnetcore-8.0-project4Models.yaml create mode 100644 bin/configs/aspnetcore-8.0-useSwashBuckle.yaml create mode 100644 bin/configs/aspnetcore-8.0.yaml create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/BasePathFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Properties/launchSettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.Development.json create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/index.html create mode 100644 samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/openapi-original.json create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/BasePathFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Properties/launchSettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Startup.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.Development.json create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/index.html create mode 100644 samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/openapi-original.json create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Dockerfile create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/BasePathFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Properties/launchSettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Startup.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.Development.json create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/index.html create mode 100644 samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Dockerfile create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/BasePathFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Properties/launchSettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Startup.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.Development.json create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/index.html create mode 100644 samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec create mode 100644 samples/server/petstore/aspnetcore-8.0/.openapi-generator-ignore create mode 100644 samples/server/petstore/aspnetcore-8.0/.openapi-generator/FILES create mode 100644 samples/server/petstore/aspnetcore-8.0/.openapi-generator/VERSION create mode 100644 samples/server/petstore/aspnetcore-8.0/Org.OpenAPITools.sln create mode 100644 samples/server/petstore/aspnetcore-8.0/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0/build.bat create mode 100644 samples/server/petstore/aspnetcore-8.0/build.sh create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/.gitignore create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/DefaultApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/FakeApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/PetApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/StoreApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/UserApi.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Dockerfile create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Animal.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/ApiResponse.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Cat.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Category.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Dog.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Order.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Pet.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Tag.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestEnum.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestNullable.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/User.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Properties/launchSettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Startup.cs create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.Development.json create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/README.md create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/index.html create mode 100644 samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/.github/workflows/samples-dotnet8-server.yaml b/.github/workflows/samples-dotnet8-server.yaml new file mode 100644 index 00000000000..a5d1e9a131d --- /dev/null +++ b/.github/workflows/samples-dotnet8-server.yaml @@ -0,0 +1,36 @@ +name: Samples C# .Net 8 Server + +on: + push: + paths: + - samples/server/petstore/aspnetcore-8.0/** + - samples/server/petstore/aspnetcore-8.0-*/** + pull_request: + paths: + - samples/server/petstore/aspnetcore-8.0/** + - samples/server/petstore/aspnetcore-8.0-*/** +jobs: + build: + name: Build .Net 8 servers + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sample: + - samples/server/petstore/aspnetcore-8.0 + - samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse + - samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes + - samples/server/petstore/aspnetcore-8.0-pocoModels + - samples/server/petstore/aspnetcore-8.0-project4Models + - samples/server/petstore/aspnetcore-8.0-useSwashBuckle + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4.0.0 + with: + dotnet-version: '8.0.x' + - name: Build + working-directory: ${{ matrix.sample }} + run: dotnet build Org.OpenAPITools.sln + - name: Test + working-directory: ${{ matrix.sample }} + run: dotnet test Org.OpenAPITools.sln diff --git a/bin/configs/aspnetcore-8.0-NewtonsoftFalse.yaml b/bin/configs/aspnetcore-8.0-NewtonsoftFalse.yaml new file mode 100644 index 00000000000..24c1a5a92a9 --- /dev/null +++ b/bin/configs/aspnetcore-8.0-NewtonsoftFalse.yaml @@ -0,0 +1,9 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' + useNewtonsoft: false diff --git a/bin/configs/aspnetcore-8.0-nullableReferenceTypes.yaml b/bin/configs/aspnetcore-8.0-nullableReferenceTypes.yaml new file mode 100644 index 00000000000..8f346e92d5d --- /dev/null +++ b/bin/configs/aspnetcore-8.0-nullableReferenceTypes.yaml @@ -0,0 +1,9 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' + nullableReferenceTypes: true \ No newline at end of file diff --git a/bin/configs/aspnetcore-8.0-pocoModels.yaml b/bin/configs/aspnetcore-8.0-pocoModels.yaml new file mode 100644 index 00000000000..799ed7e6296 --- /dev/null +++ b/bin/configs/aspnetcore-8.0-pocoModels.yaml @@ -0,0 +1,9 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0-pocoModels +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' + pocoModels: true diff --git a/bin/configs/aspnetcore-8.0-project4Models.yaml b/bin/configs/aspnetcore-8.0-project4Models.yaml new file mode 100644 index 00000000000..e4781826be1 --- /dev/null +++ b/bin/configs/aspnetcore-8.0-project4Models.yaml @@ -0,0 +1,9 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0-project4Models +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' + useSeparateModelProject: true diff --git a/bin/configs/aspnetcore-8.0-useSwashBuckle.yaml b/bin/configs/aspnetcore-8.0-useSwashBuckle.yaml new file mode 100644 index 00000000000..951da2a219f --- /dev/null +++ b/bin/configs/aspnetcore-8.0-useSwashBuckle.yaml @@ -0,0 +1,11 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0-useSwashBuckle +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' + useSwashBuckle: false + buildTarget: library + isLibrary: true diff --git a/bin/configs/aspnetcore-8.0.yaml b/bin/configs/aspnetcore-8.0.yaml new file mode 100644 index 00000000000..205fa554e55 --- /dev/null +++ b/bin/configs/aspnetcore-8.0.yaml @@ -0,0 +1,8 @@ +generatorName: aspnetcore +outputDir: samples/server/petstore/aspnetcore-8.0 +inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 +additionalProperties: + packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' + aspnetCoreVersion: "8.0" + userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md index 5dbedb169c5..9a028ed2977 100644 --- a/docs/generators/aspnetcore.md +++ b/docs/generators/aspnetcore.md @@ -18,7 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | -|aspnetCoreVersion|ASP.NET Core version: 6.0, 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)|
**2.0**
ASP.NET Core 2.0
**2.1**
ASP.NET Core 2.1
**2.2**
ASP.NET Core 2.2
**3.0**
ASP.NET Core 3.0
**3.1**
ASP.NET Core 3.1
**5.0**
ASP.NET Core 5.0
**6.0**
ASP.NET Core 6.0
|3.1| +|aspnetCoreVersion|ASP.NET Core version: 6.0, 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)|
**2.0**
ASP.NET Core 2.0
**2.1**
ASP.NET Core 2.1
**2.2**
ASP.NET Core 2.2
**3.0**
ASP.NET Core 3.0
**3.1**
ASP.NET Core 3.1
**5.0**
ASP.NET Core 5.0
**6.0**
ASP.NET Core 6.0
**7.0**
ASP.NET Core 7.0
**8.0**
ASP.NET Core 8.0
|8.0| |buildTarget|Target to build an application or library|
**program**
Generate code for a standalone server
**library**
Generate code for a server abstract class library
|program| |classModifier|Class Modifier for controller classes: Empty string or abstract.| || |compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_2| @@ -45,7 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |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| -|swashbuckleVersion|Swashbuckle version: 3.0.0 (deprecated), 4.0.0 (deprecated), 5.0.0 (deprecated), 6.4.0|
**3.0.0**
Swashbuckle 3.0.0
**4.0.0**
Swashbuckle 4.0.0
**5.0.0**
Swashbuckle 5.0.0
**6.4.0**
Swashbuckle 6.4.0
|3.0.0| +|swashbuckleVersion|Swashbuckle version: 3.0.0 (deprecated), 4.0.0 (deprecated), 5.0.0 (deprecated), 6.4.0|
**3.0.0**
Swashbuckle 3.0.0
**4.0.0**
Swashbuckle 4.0.0
**5.0.0**
Swashbuckle 5.0.0
**6.4.0**
Swashbuckle 6.4.0
|6.4.0| |useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false| |useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false| |useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java index 9f6506e254f..5a0f5e5d9af 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetServerCodegen.java @@ -186,7 +186,9 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { aspnetCoreVersion.addEnum("3.1", "ASP.NET Core 3.1"); aspnetCoreVersion.addEnum("5.0", "ASP.NET Core 5.0"); aspnetCoreVersion.addEnum("6.0", "ASP.NET Core 6.0"); - aspnetCoreVersion.setDefault("3.1"); + aspnetCoreVersion.addEnum("7.0", "ASP.NET Core 7.0"); + aspnetCoreVersion.addEnum("8.0", "ASP.NET Core 8.0"); + aspnetCoreVersion.setDefault("8.0"); aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault()); cliOptions.add(aspnetCoreVersion); @@ -194,7 +196,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { swashbuckleVersion.addEnum("4.0.0", "Swashbuckle 4.0.0"); swashbuckleVersion.addEnum("5.0.0", "Swashbuckle 5.0.0"); swashbuckleVersion.addEnum("6.4.0", "Swashbuckle 6.4.0"); - swashbuckleVersion.setDefault("3.0.0"); + swashbuckleVersion.setDefault("6.4.0"); swashbuckleVersion.setOptValue(swashbuckleVersion.getDefault()); cliOptions.add(swashbuckleVersion); @@ -427,7 +429,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("typeConverter.mustache", packageFolder + File.separator + "Converters", "CustomEnumConverter.cs")); } - if (aspnetCoreVersion.getOptValue().startsWith("3.") || aspnetCoreVersion.getOptValue().startsWith("5.0") || aspnetCoreVersion.getOptValue().startsWith("6.")) { + if (!aspnetCoreVersion.getOptValue().startsWith("2.")) { supportingFiles.add(new SupportingFile("OpenApi" + File.separator + "TypeExtensions.mustache", packageFolder + File.separator + "OpenApi", "TypeExtensions.cs")); } @@ -681,7 +683,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { private void setAspnetCoreVersion(String packageFolder) { setCliOption(aspnetCoreVersion); - if (aspnetCoreVersion.getOptValue().startsWith("3.") || aspnetCoreVersion.getOptValue().startsWith("5.0") || aspnetCoreVersion.getOptValue().startsWith("6.")) { + if (!aspnetCoreVersion.getOptValue().startsWith("2.")) { compatibilityVersion = null; } else if ("2.0".equals(aspnetCoreVersion.getOptValue())) { compatibilityVersion = null; @@ -698,6 +700,8 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { private String determineTemplateVersion(String frameworkVersion) { switch (frameworkVersion) { + case "8.0": + case "7.0": case "6.0": case "5.0": case "3.1": diff --git a/samples/client/echo_api/typescript-axios/build/package.json b/samples/client/echo_api/typescript-axios/build/package.json index e5d6921f72a..7a6fdfbb826 100644 --- a/samples/client/echo_api/typescript-axios/build/package.json +++ b/samples/client/echo_api/typescript-axios/build/package.json @@ -22,7 +22,7 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "^1.6.1" + "axios": "" }, "devDependencies": { "@types/node": "12.11.5 - 12.20.42", diff --git a/samples/client/petstore/k6/script.js b/samples/client/petstore/k6/script.js index 2d19d1f9961..7679e0ca053 100644 --- a/samples/client/petstore/k6/script.js +++ b/samples/client/petstore/k6/script.js @@ -19,10 +19,8 @@ const BASE_URL = "https://127.0.0.1/no_varaible"; // You might want to edit the value of this variable or remove calls to the sleep function on the script. const SLEEP_DURATION = 0.1; // Global variables should be initialized. -let globalApiKeyCookie = "TODO_EDIT_THE_GLOBAL_API_KEY_COOKIE"; let booleanGroup = "TODO_EDIT_THE_BOOLEAN_GROUP"; let header1 = "TODO_EDIT_THE_HEADER_1"; -let globalApiKeyHeader = "TODO_EDIT_THE_GLOBAL_API_KEY_HEADER"; let apiKey = "TODO_EDIT_THE_API_KEY"; let requiredBooleanGroup = "TODO_EDIT_THE_REQUIRED_BOOLEAN_GROUP"; let enumHeaderStringArray = "TODO_EDIT_THE_ENUM_HEADER_STRING_ARRAY"; @@ -43,9 +41,7 @@ export default function() { let body = {"enumFormStringArray": "list", "enumFormString": "string"}; let params = { headers: { - "Content-Type": "application/x-www-form-urlencoded", "enum_header_string_array": `${enumHeaderStringArray}`, "enum_header_string": `${enumHeaderString}`, "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/x-www-form-urlencoded", "enum_header_string_array": `${enumHeaderStringArray}`, "enum_header_string": `${enumHeaderString}`, "Accept": "application/json" } }; let request = http.get(url, JSON.stringify(body), params); @@ -61,9 +57,7 @@ export default function() { let body = {"client": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.patch(url, JSON.stringify(body), params); @@ -81,9 +75,7 @@ export default function() { let url = BASE_URL + `/fake/outer/boolean`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "*/*" } }; let request = http.post(url, params); @@ -103,9 +95,7 @@ export default function() { let body = {"client": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.patch(url, JSON.stringify(body), params); @@ -125,9 +115,7 @@ export default function() { let body = {"id": "long", "category": {"id": "long", "name": "string"}, "name": "string", "photoUrls": "set", "tags": "list", "status": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.put(url, JSON.stringify(body), params); @@ -146,9 +134,7 @@ export default function() { let body = {"id": "long", "category": {"id": "long", "name": "string"}, "name": "string", "photoUrls": "set", "tags": "list", "status": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -168,9 +154,7 @@ export default function() { let body = {"someProperty": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -187,14 +171,7 @@ export default function() { // Request No. 1: getUserByName { let url = BASE_URL + `/user/${username}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -206,15 +183,7 @@ export default function() { // Request No. 2: deleteUser { let url = BASE_URL + `/user/${username}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - // this is a DELETE method request - if params are also set, empty body must be passed - let request = http.del(url, {} , params); + let request = http.del(url); } }); @@ -226,9 +195,7 @@ export default function() { let url = BASE_URL + `/fake/body-with-binary`; let params = { headers: { - "Content-Type": "image/png", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "image/png", "Accept": "application/json" } }; let request = http.put(url, params); @@ -248,9 +215,7 @@ export default function() { let body = {"type": "string", "nullableProperty": "string", "otherProperty": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -270,9 +235,7 @@ export default function() { let body = {"client": "string"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.patch(url, JSON.stringify(body), params); @@ -290,9 +253,7 @@ export default function() { let url = BASE_URL + `/user/createWithList`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, params); @@ -310,9 +271,7 @@ export default function() { let url = BASE_URL + `/fake/inline-additionalProperties`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, params); @@ -328,14 +287,7 @@ export default function() { // Request No. 1: getInventory { let url = BASE_URL + `/store/inventory`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -350,14 +302,7 @@ export default function() { // Request No. 1: loginUser { let url = BASE_URL + `/user/login?username=${username}&password=${password}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -372,9 +317,7 @@ export default function() { let url = BASE_URL + `/fake/stringMap-reference`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, params); @@ -394,9 +337,7 @@ export default function() { let body = {"myNumber": "bigdecimal", "myString": "string", "myBoolean": "boolean"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "*/*" } }; let request = http.post(url, JSON.stringify(body), params); @@ -416,9 +357,7 @@ export default function() { let body = {"param": "string", "param2": "string"}; let params = { headers: { - "Content-Type": "application/x-www-form-urlencoded", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json" } }; let request = http.get(url, JSON.stringify(body), params); @@ -439,9 +378,7 @@ export default function() { let body = {"additionalMetadata": "string", "requiredFile": http.file(open("/path/to/file.bin", "b"), "test.bin")}; let params = { headers: { - "Content-Type": "multipart/form-data", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "multipart/form-data", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -458,14 +395,7 @@ export default function() { // Request No. 1: getPetById { let url = BASE_URL + `/pet/${petId}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -479,9 +409,7 @@ export default function() { let url = BASE_URL + `/pet/${petId}`; let params = { headers: { - "api_key": `${apiKey}`, "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "api_key": `${apiKey}`, "Accept": "application/json" } }; // this is a DELETE method request - if params are also set, empty body must be passed @@ -498,14 +426,7 @@ export default function() { // Request No. 1: { let url = BASE_URL + `/foo`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "response": (r) => r.status === 200 @@ -520,9 +441,7 @@ export default function() { let url = BASE_URL + `/fake/outer/string`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "*/*" } }; let request = http.post(url, params); @@ -545,14 +464,7 @@ export default function() { // Request No. 1: testQueryParameterCollectionFormat { let url = BASE_URL + `/fake/test-query-parameters?pipe=${pipe}&ioutil=${ioutil}&http=${http}&url=${url}&context=${context}&language=${language}&allowEmpty=${allowEmpty}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.put(url, params); + let request = http.put(url); check(request, { "Success": (r) => r.status === 200 @@ -566,14 +478,7 @@ export default function() { // Request No. 1: getOrderById { let url = BASE_URL + `/store/order/${order_id}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -585,15 +490,7 @@ export default function() { // Request No. 2: deleteOrder { let url = BASE_URL + `/store/order/${order_id}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - // this is a DELETE method request - if params are also set, empty body must be passed - let request = http.del(url, {} , params); + let request = http.del(url); } }); @@ -605,9 +502,7 @@ export default function() { let url = BASE_URL + `/fake/additionalProperties-reference`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, params); @@ -624,14 +519,7 @@ export default function() { // Request No. 1: findPetsByStatus { let url = BASE_URL + `/pet/findByStatus?status=${status}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -649,9 +537,7 @@ export default function() { let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.put(url, JSON.stringify(body), params); @@ -672,9 +558,7 @@ export default function() { let body = {"additionalMetadata": "string", "file": http.file(open("/path/to/file.bin", "b"), "test.bin")}; let params = { headers: { - "Content-Type": "multipart/form-data", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "multipart/form-data", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -695,9 +579,7 @@ export default function() { let body = {"id": "long", "category": {"id": "long", "name": "string"}, "name": "string", "photoUrls": "set", "tags": "list", "status": "string"}; let params = { headers: { - "Content-Type": "application/json", "header_1": `${header1}`, "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "header_1": `${header1}`, "Accept": "application/json" } }; let request = http.get(url, JSON.stringify(body), params); @@ -717,9 +599,7 @@ export default function() { let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -739,9 +619,7 @@ export default function() { let body = {"value": "outerenuminteger"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "*/*" } }; let request = http.post(url, JSON.stringify(body), params); @@ -759,9 +637,7 @@ export default function() { let url = BASE_URL + `/user/createWithArray`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, params); @@ -781,9 +657,7 @@ export default function() { let body = {"file": http.file(open("/path/to/file.bin", "b"), "test.bin"), "files": "list"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.put(url, JSON.stringify(body), params); @@ -800,14 +674,7 @@ export default function() { // Request No. 1: findPetsByTags { let url = BASE_URL + `/pet/findByTags?tags=${tags}`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -824,9 +691,7 @@ export default function() { let body = {"id": "long", "petId": "long", "quantity": "integer", "shipDate": "date", "status": "string", "complete": "boolean"}; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "application/json" } }; let request = http.post(url, JSON.stringify(body), params); @@ -842,14 +707,7 @@ export default function() { // Request No. 1: logoutUser { let url = BASE_URL + `/user/logout`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -862,14 +720,7 @@ export default function() { // Request No. 1: fakeBigDecimalMap { let url = BASE_URL + `/fake/BigDecimalMap`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "successful operation": (r) => r.status === 200 @@ -882,14 +733,7 @@ export default function() { // Request No. 1: { let url = BASE_URL + `/fake/health`; - let params = { - headers: { - "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` - } - }; - let request = http.get(url, params); + let request = http.get(url); check(request, { "The instance started successfully": (r) => r.status === 200 @@ -904,9 +748,7 @@ export default function() { let url = BASE_URL + `/fake/outer/number`; let params = { headers: { - "Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "*/*" - }, cookies: { - "global_api_key_cookie": `${globalApiKeyCookie}` + "Content-Type": "application/json", "Accept": "*/*" } }; let request = http.post(url, params); diff --git a/samples/client/petstore/typescript-axios/builds/es6-target/package.json b/samples/client/petstore/typescript-axios/builds/es6-target/package.json index 2c6217f2d80..6b58df56d55 100644 --- a/samples/client/petstore/typescript-axios/builds/es6-target/package.json +++ b/samples/client/petstore/typescript-axios/builds/es6-target/package.json @@ -24,7 +24,7 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "^1.6.1" + "axios": "" }, "devDependencies": { "@types/node": "12.11.5 - 12.20.42", diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json index aa938d8bf65..8a493d5b519 100644 --- a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json @@ -22,7 +22,7 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "^1.6.1" + "axios": "" }, "devDependencies": { "@types/node": "12.11.5 - 12.20.42", diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version/package.json b/samples/client/petstore/typescript-axios/builds/with-npm-version/package.json index aa938d8bf65..8a493d5b519 100644 --- a/samples/client/petstore/typescript-axios/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version/package.json @@ -22,7 +22,7 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "^1.6.1" + "axios": "" }, "devDependencies": { "@types/node": "12.11.5 - 12.20.42", diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts index 4d81b3f9698..2b247b983ff 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts @@ -40,8 +40,6 @@ export interface AllOfWithSingleRef { singleRefType?: SingleRefType; } - - /** * Check if a given object implements the AllOfWithSingleRef interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts index 47e184b3414..c8ca1734039 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts @@ -34,8 +34,6 @@ export interface OuterObjectWithEnumProperty { value: OuterEnumInteger; } - - /** * Check if a given object implements the OuterObjectWithEnumProperty interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts b/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts index 576b5fde62d..fc2c493f04c 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts @@ -58,8 +58,6 @@ export interface EnumPatternObject { nullableNumberEnum?: NumberEnum | null; } - - /** * Check if a given object implements the EnumPatternObject interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts index f3d8f640f8b..5de27f58461 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts @@ -46,8 +46,6 @@ export interface GetBehaviorTypeResponse { data?: BehaviorType; } - - /** * Check if a given object implements the GetBehaviorTypeResponse interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts index 5e2f514633c..16ec3947673 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts @@ -46,8 +46,6 @@ export interface GetPetPartTypeResponse { data?: PetPartType; } - - /** * Check if a given object implements the GetPetPartTypeResponse interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts index 4d81b3f9698..2b247b983ff 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts @@ -40,8 +40,6 @@ export interface AllOfWithSingleRef { singleRefType?: SingleRefType; } - - /** * Check if a given object implements the AllOfWithSingleRef interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts index 47e184b3414..c8ca1734039 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts @@ -34,8 +34,6 @@ export interface OuterObjectWithEnumProperty { value: OuterEnumInteger; } - - /** * Check if a given object implements the OuterObjectWithEnumProperty interface. */ diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts index 576b5fde62d..fc2c493f04c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts @@ -58,8 +58,6 @@ export interface EnumPatternObject { nullableNumberEnum?: NumberEnum | null; } - - /** * Check if a given object implements the EnumPatternObject interface. */ diff --git a/samples/server/petstore/aspnetcore-3.1/README.md b/samples/server/petstore/aspnetcore-3.1/README.md index cb9541519ea..5da4721474e 100644 --- a/samples/server/petstore/aspnetcore-3.1/README.md +++ b/samples/server/petstore/aspnetcore-3.1/README.md @@ -1,4 +1,4 @@ -# Org.OpenAPITools - ASP.NET Core 3.1 Server +# Org.OpenAPITools - ASP.NET Core 8.0 Server This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Dockerfile index 9fe18ee2ba3..c24f45dbc5a 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Dockerfile @@ -1,13 +1,13 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. # Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443 # Build container -FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build # Copy the code into the container WORKDIR /src diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Startup.cs index b684e16a2d9..0adda89acc0 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Startup.cs +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Startup.cs @@ -84,7 +84,7 @@ namespace Org.OpenAPITools c.SwaggerDoc("1.0.0", new OpenApiInfo { Title = "OpenAPI Petstore", - Description = "OpenAPI Petstore (ASP.NET Core 3.1)", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), Contact = new OpenApiContact { diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/FILES new file mode 100644 index 00000000000..5813de3b53b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/FILES @@ -0,0 +1,38 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools/Dockerfile +src/Org.OpenAPITools/Filters/BasePathFilter.cs +src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/Models/Animal.cs +src/Org.OpenAPITools/Models/ApiResponse.cs +src/Org.OpenAPITools/Models/Cat.cs +src/Org.OpenAPITools/Models/Category.cs +src/Org.OpenAPITools/Models/Dog.cs +src/Org.OpenAPITools/Models/Order.cs +src/Org.OpenAPITools/Models/Pet.cs +src/Org.OpenAPITools/Models/Tag.cs +src/Org.OpenAPITools/Models/TestEnum.cs +src/Org.OpenAPITools/Models/TestNullable.cs +src/Org.OpenAPITools/Models/User.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Program.cs +src/Org.OpenAPITools/Properties/launchSettings.json +src/Org.OpenAPITools/Startup.cs +src/Org.OpenAPITools/appsettings.Development.json +src/Org.OpenAPITools/appsettings.json +src/Org.OpenAPITools/wwwroot/README.md +src/Org.OpenAPITools/wwwroot/index.html +src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/Org.OpenAPITools.sln new file mode 100644 index 00000000000..c2bc3876420 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/Org.OpenAPITools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/README.md b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/README.md new file mode 100644 index 00000000000..5da4721474e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/README.md @@ -0,0 +1,50 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` +## Run in Docker + +``` +cd src/Org.OpenAPITools +docker build -t org.openapitools . +docker run -p 5000:8080 org.openapitools +``` diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.bat b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.sh b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..315555e2a44 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..3d7fbb77b0d --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Text.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + [SwaggerOperation("TestGet")] + public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..6dd12a5fd68 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Text.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeNullableExampleTest")] + [SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")] + public virtual IActionResult FakeNullableExampleTest() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(TestNullable)); + string exampleJson = null; + exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(TestNullable); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeParameterExampleTest")] + public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..d4230ca5a4c --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,260 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Text.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("AddPet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult AddPet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + [SwaggerOperation("DeletePet")] + public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + throw new NotImplementedException(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + [Obsolete] + public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("UpdatePet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult UpdatePet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n doggie\n \n aeiou\n \n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + [SwaggerOperation("UpdatePetWithForm")] + public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status) + { + + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + + throw new NotImplementedException(); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [SwaggerOperation("UploadFile")] + [SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")] + public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(ApiResponse)); + string exampleJson = null; + exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(ApiResponse); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..2c52f026791 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,141 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Text.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("DeleteOrder")] + public virtual IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(statusCode: 200, type: typeof(Dictionary), description: "successful operation")] + public virtual IActionResult GetInventory() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Dictionary)); + string exampleJson = null; + + var example = exampleJson != null + ? JsonSerializer.Deserialize>(exampleJson) + : new Dictionary(); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("PlaceOrder")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult PlaceOrder([FromBody]Order order) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..5a0951513f3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Text.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUser")] + public virtual IActionResult CreateUser([FromBody]User user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithArrayInput")] + public virtual IActionResult CreateUsersWithArrayInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithListInput")] + public virtual IActionResult CreateUsersWithListInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("DeleteUser")] + public virtual IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")] + public virtual IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(User)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}"; + exampleJson = "\n 123456789\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n 123\n"; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(User); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + [SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")] + public virtual IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(string)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + + var example = exampleJson != null + ? JsonSerializer.Deserialize(exampleJson) + : default(string); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("LogoutUser")] + public virtual IActionResult LogoutUser() + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("UpdateUser")] + public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..cdd3d463721 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Text.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonSerializer.Deserialize(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile new file mode 100644 index 00000000000..c24f45dbc5a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/BasePathFilter.cs new file mode 100644 index 00000000000..97ae99c9295 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 00000000000..9eccd5c317f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Animal.cs new file mode 100644 index 00000000000..6172a1b27e9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Animal.cs @@ -0,0 +1,146 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using JsonSubTypes; +using Swashbuckle.AspNetCore.Annotations; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [SwaggerDiscriminator("ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [SwaggerSubType(typeof(Cat), DiscriminatorValue = "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + [SwaggerSubType(typeof(Dog), DiscriminatorValue = "DOG")] + public partial class Animal : IEquatable + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } = "red"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Animal)obj); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ClassName == other.ClassName || + ClassName != null && + ClassName.Equals(other.ClassName) + ) && + ( + Color == other.Color || + Color != null && + Color.Equals(other.Color) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (ClassName != null) + hashCode = hashCode * 59 + ClassName.GetHashCode(); + if (Color != null) + hashCode = hashCode * 59 + Color.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Animal left, Animal right) + { + return Equals(left, right); + } + + public static bool operator !=(Animal left, Animal right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/ApiResponse.cs new file mode 100644 index 00000000000..9362efa8367 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/ApiResponse.cs @@ -0,0 +1,152 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public partial class ApiResponse : IEquatable + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ApiResponse)obj); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + + Code.Equals(other.Code) + ) && + ( + Type == other.Type || + Type != null && + Type.Equals(other.Type) + ) && + ( + Message == other.Message || + Message != null && + Message.Equals(other.Message) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Code.GetHashCode(); + if (Type != null) + hashCode = hashCode * 59 + Type.GetHashCode(); + if (Message != null) + hashCode = hashCode * 59 + Message.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ApiResponse left, ApiResponse right) + { + return Equals(left, right); + } + + public static bool operator !=(ApiResponse left, ApiResponse right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Cat.cs new file mode 100644 index 00000000000..01639d12eed --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Cat.cs @@ -0,0 +1,124 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal, IEquatable + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Cat)obj); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Declawed == other.Declawed || + + Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Declawed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Cat left, Cat right) + { + return Equals(left, right); + } + + public static bool operator !=(Cat left, Cat right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Category.cs new file mode 100644 index 00000000000..11eac79c541 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Category.cs @@ -0,0 +1,139 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public partial class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Category)obj); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Category left, Category right) + { + return Equals(left, right); + } + + public static bool operator !=(Category left, Category right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Dog.cs new file mode 100644 index 00000000000..c08f6b036d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Dog.cs @@ -0,0 +1,124 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal, IEquatable + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Dog)obj); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Breed == other.Breed || + Breed != null && + Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Breed != null) + hashCode = hashCode * 59 + Breed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Dog left, Dog right) + { + return Equals(left, right); + } + + public static bool operator !=(Dog left, Dog right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Order.cs new file mode 100644 index 00000000000..cbf41566ae1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Order.cs @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public partial class Order : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool Complete { get; set; } = false; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Order)obj); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + PetId == other.PetId || + + PetId.Equals(other.PetId) + ) && + ( + Quantity == other.Quantity || + + Quantity.Equals(other.Quantity) + ) && + ( + ShipDate == other.ShipDate || + + ShipDate.Equals(other.ShipDate) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ) && + ( + Complete == other.Complete || + + Complete.Equals(other.Complete) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + + hashCode = hashCode * 59 + PetId.GetHashCode(); + + hashCode = hashCode * 59 + Quantity.GetHashCode(); + + hashCode = hashCode * 59 + ShipDate.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + + hashCode = hashCode * 59 + Complete.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Order left, Order right) + { + return Equals(left, right); + } + + public static bool operator !=(Order left, Order right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Pet.cs new file mode 100644 index 00000000000..8b9f57ddc85 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Pet.cs @@ -0,0 +1,228 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public partial class Pet : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Pet)obj); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Category == other.Category || + Category != null && + Category.Equals(other.Category) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + PhotoUrls == other.PhotoUrls || + PhotoUrls != null && + other.PhotoUrls != null && + PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + Tags == other.Tags || + Tags != null && + other.Tags != null && + Tags.SequenceEqual(other.Tags) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Category != null) + hashCode = hashCode * 59 + Category.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (PhotoUrls != null) + hashCode = hashCode * 59 + PhotoUrls.GetHashCode(); + if (Tags != null) + hashCode = hashCode * 59 + Tags.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Pet left, Pet right) + { + return Equals(left, right); + } + + public static bool operator !=(Pet left, Pet right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Tag.cs new file mode 100644 index 00000000000..0a40e7f333e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/Tag.cs @@ -0,0 +1,138 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public partial class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Tag)obj); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Tag left, Tag right) + { + return Equals(left, right); + } + + public static bool operator !=(Tag left, Tag right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestEnum.cs new file mode 100644 index 00000000000..8777bf97e8d --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestEnum.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestNullable.cs new file mode 100644 index 00000000000..18d3b5347c2 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/TestNullable.cs @@ -0,0 +1,138 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class TestNullable : IEquatable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string NullableName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TestNullable {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" NullableName: ").Append(NullableName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((TestNullable)obj); + } + + /// + /// Returns true if TestNullable instances are equal + /// + /// Instance of TestNullable to be compared + /// Boolean + public bool Equals(TestNullable other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + NullableName == other.NullableName || + NullableName != null && + NullableName.Equals(other.NullableName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (NullableName != null) + hashCode = hashCode * 59 + NullableName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(TestNullable left, TestNullable right) + { + return Equals(left, right); + } + + public static bool operator !=(TestNullable left, TestNullable right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/User.cs new file mode 100644 index 00000000000..49dd6ebe212 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Models/User.cs @@ -0,0 +1,223 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using System.Text.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public partial class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + var options = new JsonSerializerOptions + { + WriteIndented = true + }; + + return JsonSerializer.Serialize(this, options); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((User)obj); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Username == other.Username || + Username != null && + Username.Equals(other.Username) + ) && + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ) && + ( + Phone == other.Phone || + Phone != null && + Phone.Equals(other.Phone) + ) && + ( + UserStatus == other.UserStatus || + + UserStatus.Equals(other.UserStatus) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Username != null) + hashCode = hashCode * 59 + Username.GetHashCode(); + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + if (Phone != null) + hashCode = hashCode * 59 + Phone.GetHashCode(); + + hashCode = hashCode * 59 + UserStatus.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(User left, User right) + { + return Equals(left, right); + } + + public static bool operator !=(User left, User right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..9cc715ffd9f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,26 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs new file mode 100644 index 00000000000..00ed16ed675 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Properties/launchSettings.json new file mode 100644 index 00000000000..99cfeea4b91 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "openapi", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OpenAPI": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "openapi", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/openapi", + "publishAllPorts": true, + "useSSL": true + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs new file mode 100644 index 00000000000..d2700aa1da7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,150 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using System.Text.Json; +using System.Text.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddJsonOptions(options => + { + options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.Development.json b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.Development.json new file mode 100644 index 00000000000..e203e9407e7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json new file mode 100644 index 00000000000..def9159a7d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/README.md b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/index.html b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/index.html new file mode 100644 index 00000000000..f3318bc90a1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/index.html @@ -0,0 +1 @@ + diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/openapi-original.json new file mode 100644 index 00000000000..b47dce3d2c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/FILES new file mode 100644 index 00000000000..5813de3b53b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/FILES @@ -0,0 +1,38 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools/Dockerfile +src/Org.OpenAPITools/Filters/BasePathFilter.cs +src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/Models/Animal.cs +src/Org.OpenAPITools/Models/ApiResponse.cs +src/Org.OpenAPITools/Models/Cat.cs +src/Org.OpenAPITools/Models/Category.cs +src/Org.OpenAPITools/Models/Dog.cs +src/Org.OpenAPITools/Models/Order.cs +src/Org.OpenAPITools/Models/Pet.cs +src/Org.OpenAPITools/Models/Tag.cs +src/Org.OpenAPITools/Models/TestEnum.cs +src/Org.OpenAPITools/Models/TestNullable.cs +src/Org.OpenAPITools/Models/User.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Program.cs +src/Org.OpenAPITools/Properties/launchSettings.json +src/Org.OpenAPITools/Startup.cs +src/Org.OpenAPITools/appsettings.Development.json +src/Org.OpenAPITools/appsettings.json +src/Org.OpenAPITools/wwwroot/README.md +src/Org.OpenAPITools/wwwroot/index.html +src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/Org.OpenAPITools.sln new file mode 100644 index 00000000000..c2bc3876420 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/Org.OpenAPITools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/README.md b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/README.md new file mode 100644 index 00000000000..5da4721474e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/README.md @@ -0,0 +1,50 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` +## Run in Docker + +``` +cd src/Org.OpenAPITools +docker build -t org.openapitools . +docker run -p 5000:8080 org.openapitools +``` diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.bat b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.sh b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..23d737e9bf0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object? args = null; + if (parameter.Name != null && context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object? args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid && parameter.Name != null) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..beabdde2fb1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + [SwaggerOperation("TestGet")] + public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..a0f2bd3b231 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeNullableExampleTest")] + [SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")] + public virtual IActionResult FakeNullableExampleTest() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(TestNullable)); + string exampleJson = null; + exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(TestNullable); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeParameterExampleTest")] + public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..fae01d29a62 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,260 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("AddPet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult AddPet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + [SwaggerOperation("DeletePet")] + public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string? apiKey) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + throw new NotImplementedException(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + [Obsolete] + public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("UpdatePet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult UpdatePet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n doggie\n \n aeiou\n \n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + [SwaggerOperation("UpdatePetWithForm")] + public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string? name, [FromForm (Name = "status")]string? status) + { + + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + + throw new NotImplementedException(); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [SwaggerOperation("UploadFile")] + [SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")] + public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string? additionalMetadata, IFormFile file) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(ApiResponse)); + string exampleJson = null; + exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(ApiResponse); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..b925426c761 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,141 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("DeleteOrder")] + public virtual IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(statusCode: 200, type: typeof(Dictionary), description: "successful operation")] + public virtual IActionResult GetInventory() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Dictionary)); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : new Dictionary(); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("PlaceOrder")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult PlaceOrder([FromBody]Order order) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..6d7094c81a9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUser")] + public virtual IActionResult CreateUser([FromBody]User user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithArrayInput")] + public virtual IActionResult CreateUsersWithArrayInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithListInput")] + public virtual IActionResult CreateUsersWithListInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("DeleteUser")] + public virtual IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")] + public virtual IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(User)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}"; + exampleJson = "\n 123456789\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n 123\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(User); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + [SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")] + public virtual IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(string)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(string); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("LogoutUser")] + public virtual IActionResult LogoutUser() + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("UpdateUser")] + public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..32303e7a410 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonConvert.DeserializeObject(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile new file mode 100644 index 00000000000..c24f45dbc5a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/BasePathFilter.cs new file mode 100644 index 00000000000..97ae99c9295 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 00000000000..9eccd5c317f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Animal.cs new file mode 100644 index 00000000000..c9da013dc71 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Animal.cs @@ -0,0 +1,142 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using JsonSubTypes; +using Swashbuckle.AspNetCore.Annotations; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [SwaggerDiscriminator("ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [SwaggerSubType(typeof(Cat), DiscriminatorValue = "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + [SwaggerSubType(typeof(Dog), DiscriminatorValue = "DOG")] + public partial class Animal : IEquatable + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string? Color { get; set; } = "red"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Animal)obj); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ClassName == other.ClassName || + ClassName != null && + ClassName.Equals(other.ClassName) + ) && + ( + Color == other.Color || + Color != null && + Color.Equals(other.Color) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (ClassName != null) + hashCode = hashCode * 59 + ClassName.GetHashCode(); + if (Color != null) + hashCode = hashCode * 59 + Color.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Animal left, Animal right) + { + return Equals(left, right); + } + + public static bool operator !=(Animal left, Animal right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/ApiResponse.cs new file mode 100644 index 00000000000..638c1313710 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/ApiResponse.cs @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public partial class ApiResponse : IEquatable + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int? Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string? Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string? Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ApiResponse)obj); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + + Code.Equals(other.Code) + ) && + ( + Type == other.Type || + Type != null && + Type.Equals(other.Type) + ) && + ( + Message == other.Message || + Message != null && + Message.Equals(other.Message) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Code.GetHashCode(); + if (Type != null) + hashCode = hashCode * 59 + Type.GetHashCode(); + if (Message != null) + hashCode = hashCode * 59 + Message.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ApiResponse left, ApiResponse right) + { + return Equals(left, right); + } + + public static bool operator !=(ApiResponse left, ApiResponse right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Cat.cs new file mode 100644 index 00000000000..710b6a34d82 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Cat.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal, IEquatable + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool? Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Cat)obj); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Declawed == other.Declawed || + + Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Declawed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Cat left, Cat right) + { + return Equals(left, right); + } + + public static bool operator !=(Cat left, Cat right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Category.cs new file mode 100644 index 00000000000..e9718bd5ca0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Category.cs @@ -0,0 +1,134 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public partial class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string? Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Category)obj); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Category left, Category right) + { + return Equals(left, right); + } + + public static bool operator !=(Category left, Category right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Dog.cs new file mode 100644 index 00000000000..5ea23a2f881 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Dog.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal, IEquatable + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string? Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Dog)obj); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Breed == other.Breed || + Breed != null && + Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Breed != null) + hashCode = hashCode * 59 + Breed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Dog left, Dog right) + { + return Equals(left, right); + } + + public static bool operator !=(Dog left, Dog right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Order.cs new file mode 100644 index 00000000000..626ad7c4e84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Order.cs @@ -0,0 +1,219 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public partial class Order : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long? Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long? PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int? Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime? ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool? Complete { get; set; } = false; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Order)obj); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + PetId == other.PetId || + + PetId.Equals(other.PetId) + ) && + ( + Quantity == other.Quantity || + + Quantity.Equals(other.Quantity) + ) && + ( + ShipDate == other.ShipDate || + + ShipDate.Equals(other.ShipDate) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ) && + ( + Complete == other.Complete || + + Complete.Equals(other.Complete) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + + hashCode = hashCode * 59 + PetId.GetHashCode(); + + hashCode = hashCode * 59 + Quantity.GetHashCode(); + + hashCode = hashCode * 59 + ShipDate.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + + hashCode = hashCode * 59 + Complete.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Order left, Order right) + { + return Equals(left, right); + } + + public static bool operator !=(Order left, Order right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Pet.cs new file mode 100644 index 00000000000..69a963a25f2 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Pet.cs @@ -0,0 +1,224 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public partial class Pet : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long? Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category? Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Pet)obj); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Category == other.Category || + Category != null && + Category.Equals(other.Category) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + PhotoUrls == other.PhotoUrls || + PhotoUrls != null && + other.PhotoUrls != null && + PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + Tags == other.Tags || + Tags != null && + other.Tags != null && + Tags.SequenceEqual(other.Tags) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Category != null) + hashCode = hashCode * 59 + Category.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (PhotoUrls != null) + hashCode = hashCode * 59 + PhotoUrls.GetHashCode(); + if (Tags != null) + hashCode = hashCode * 59 + Tags.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Pet left, Pet right) + { + return Equals(left, right); + } + + public static bool operator !=(Pet left, Pet right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Tag.cs new file mode 100644 index 00000000000..4d7834b4c52 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/Tag.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public partial class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string? Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Tag)obj); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Tag left, Tag right) + { + return Equals(left, right); + } + + public static bool operator !=(Tag left, Tag right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestEnum.cs new file mode 100644 index 00000000000..10227a2a2c4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestEnum.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestNullable.cs new file mode 100644 index 00000000000..c07abecc09a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/TestNullable.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class TestNullable : IEquatable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string? Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string? NullableName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TestNullable {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" NullableName: ").Append(NullableName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((TestNullable)obj); + } + + /// + /// Returns true if TestNullable instances are equal + /// + /// Instance of TestNullable to be compared + /// Boolean + public bool Equals(TestNullable other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + NullableName == other.NullableName || + NullableName != null && + NullableName.Equals(other.NullableName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (NullableName != null) + hashCode = hashCode * 59 + NullableName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(TestNullable left, TestNullable right) + { + return Equals(left, right); + } + + public static bool operator !=(TestNullable left, TestNullable right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/User.cs new file mode 100644 index 00000000000..4d07fc1ef74 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Models/User.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public partial class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long? Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string? Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string? FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string? LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string? Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string? Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string? Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int? UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((User)obj); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Username == other.Username || + Username != null && + Username.Equals(other.Username) + ) && + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ) && + ( + Phone == other.Phone || + Phone != null && + Phone.Equals(other.Phone) + ) && + ( + UserStatus == other.UserStatus || + + UserStatus.Equals(other.UserStatus) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Username != null) + hashCode = hashCode * 59 + Username.GetHashCode(); + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + if (Phone != null) + hashCode = hashCode * 59 + Phone.GetHashCode(); + + hashCode = hashCode * 59 + UserStatus.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(User left, User right) + { + return Equals(left, right); + } + + public static bool operator !=(User left, User right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..734cc7dbef4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,28 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + annotations + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs new file mode 100644 index 00000000000..00ed16ed675 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Properties/launchSettings.json new file mode 100644 index 00000000000..99cfeea4b91 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "openapi", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OpenAPI": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "openapi", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/openapi", + "publishAllPorts": true, + "useSSL": true + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Startup.cs new file mode 100644 index 00000000000..0adda89acc0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,155 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter + { + NamingStrategy = new CamelCaseNamingStrategy() + }); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + services + .AddSwaggerGenNewtonsoftSupport(); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.Development.json b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.Development.json new file mode 100644 index 00000000000..e203e9407e7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.json new file mode 100644 index 00000000000..def9159a7d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/README.md b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/index.html b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/index.html new file mode 100644 index 00000000000..f3318bc90a1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/index.html @@ -0,0 +1 @@ + diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/openapi-original.json new file mode 100644 index 00000000000..b47dce3d2c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0-pocoModels/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/FILES new file mode 100644 index 00000000000..5813de3b53b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/FILES @@ -0,0 +1,38 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools/Dockerfile +src/Org.OpenAPITools/Filters/BasePathFilter.cs +src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/Models/Animal.cs +src/Org.OpenAPITools/Models/ApiResponse.cs +src/Org.OpenAPITools/Models/Cat.cs +src/Org.OpenAPITools/Models/Category.cs +src/Org.OpenAPITools/Models/Dog.cs +src/Org.OpenAPITools/Models/Order.cs +src/Org.OpenAPITools/Models/Pet.cs +src/Org.OpenAPITools/Models/Tag.cs +src/Org.OpenAPITools/Models/TestEnum.cs +src/Org.OpenAPITools/Models/TestNullable.cs +src/Org.OpenAPITools/Models/User.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Program.cs +src/Org.OpenAPITools/Properties/launchSettings.json +src/Org.OpenAPITools/Startup.cs +src/Org.OpenAPITools/appsettings.Development.json +src/Org.OpenAPITools/appsettings.json +src/Org.OpenAPITools/wwwroot/README.md +src/Org.OpenAPITools/wwwroot/index.html +src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0-pocoModels/Org.OpenAPITools.sln new file mode 100644 index 00000000000..c2bc3876420 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/Org.OpenAPITools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/README.md b/samples/server/petstore/aspnetcore-8.0-pocoModels/README.md new file mode 100644 index 00000000000..5da4721474e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/README.md @@ -0,0 +1,50 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` +## Run in Docker + +``` +cd src/Org.OpenAPITools +docker build -t org.openapitools . +docker run -p 5000:8080 org.openapitools +``` diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/build.bat b/samples/server/petstore/aspnetcore-8.0-pocoModels/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/build.sh b/samples/server/petstore/aspnetcore-8.0-pocoModels/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..315555e2a44 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..beabdde2fb1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + [SwaggerOperation("TestGet")] + public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..a0f2bd3b231 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeNullableExampleTest")] + [SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")] + public virtual IActionResult FakeNullableExampleTest() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(TestNullable)); + string exampleJson = null; + exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(TestNullable); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeParameterExampleTest")] + public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..7dded4e0f16 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,260 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("AddPet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult AddPet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + [SwaggerOperation("DeletePet")] + public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + throw new NotImplementedException(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + [Obsolete] + public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("UpdatePet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult UpdatePet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n doggie\n \n aeiou\n \n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + [SwaggerOperation("UpdatePetWithForm")] + public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status) + { + + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + + throw new NotImplementedException(); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [SwaggerOperation("UploadFile")] + [SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")] + public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(ApiResponse)); + string exampleJson = null; + exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(ApiResponse); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..b925426c761 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,141 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("DeleteOrder")] + public virtual IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(statusCode: 200, type: typeof(Dictionary), description: "successful operation")] + public virtual IActionResult GetInventory() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Dictionary)); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : new Dictionary(); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("PlaceOrder")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult PlaceOrder([FromBody]Order order) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..6d7094c81a9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUser")] + public virtual IActionResult CreateUser([FromBody]User user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithArrayInput")] + public virtual IActionResult CreateUsersWithArrayInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithListInput")] + public virtual IActionResult CreateUsersWithListInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("DeleteUser")] + public virtual IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")] + public virtual IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(User)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}"; + exampleJson = "\n 123456789\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n 123\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(User); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + [SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")] + public virtual IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(string)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(string); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("LogoutUser")] + public virtual IActionResult LogoutUser() + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("UpdateUser")] + public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..7d1a4ed4ffb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonConvert.DeserializeObject(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Dockerfile new file mode 100644 index 00000000000..c24f45dbc5a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/BasePathFilter.cs new file mode 100644 index 00000000000..97ae99c9295 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 00000000000..9eccd5c317f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Animal.cs new file mode 100644 index 00000000000..c7a6ae09eaa --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Animal.cs @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using JsonSubTypes; +using Swashbuckle.AspNetCore.Annotations; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [SwaggerDiscriminator("ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [SwaggerSubType(typeof(Cat), DiscriminatorValue = "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + [SwaggerSubType(typeof(Dog), DiscriminatorValue = "DOG")] + public partial class Animal + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } = "red"; + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/ApiResponse.cs new file mode 100644 index 00000000000..223b4a4d656 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/ApiResponse.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public partial class ApiResponse + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Cat.cs new file mode 100644 index 00000000000..537c0f7f714 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Cat.cs @@ -0,0 +1,36 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool Declawed { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Category.cs new file mode 100644 index 00000000000..a453e45e115 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Category.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public partial class Category + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Dog.cs new file mode 100644 index 00000000000..f1a52695233 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Dog.cs @@ -0,0 +1,36 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Order.cs new file mode 100644 index 00000000000..7a68506eaa4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Order.cs @@ -0,0 +1,96 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public partial class Order + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool Complete { get; set; } = false; + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Pet.cs new file mode 100644 index 00000000000..fa3ddfa5110 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Pet.cs @@ -0,0 +1,99 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public partial class Pet + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Tag.cs new file mode 100644 index 00000000000..8dfa88aa9da --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/Tag.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public partial class Tag + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestEnum.cs new file mode 100644 index 00000000000..10227a2a2c4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestEnum.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestNullable.cs new file mode 100644 index 00000000000..f2b9c2ebe47 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/TestNullable.cs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class TestNullable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string NullableName { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/User.cs new file mode 100644 index 00000000000..fb756914eb5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Models/User.cs @@ -0,0 +1,79 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public partial class User + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int UserStatus { get; set; } + + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..745c764b501 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,27 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs new file mode 100644 index 00000000000..00ed16ed675 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Properties/launchSettings.json new file mode 100644 index 00000000000..99cfeea4b91 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "openapi", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OpenAPI": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "openapi", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/openapi", + "publishAllPorts": true, + "useSSL": true + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Startup.cs new file mode 100644 index 00000000000..0adda89acc0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,155 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter + { + NamingStrategy = new CamelCaseNamingStrategy() + }); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + services + .AddSwaggerGenNewtonsoftSupport(); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.Development.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.Development.json new file mode 100644 index 00000000000..e203e9407e7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json new file mode 100644 index 00000000000..def9159a7d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/README.md b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/index.html b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/index.html new file mode 100644 index 00000000000..f3318bc90a1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/index.html @@ -0,0 +1 @@ + diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json new file mode 100644 index 00000000000..b47dce3d2c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0-project4Models/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/FILES new file mode 100644 index 00000000000..2f0226d29bc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/FILES @@ -0,0 +1,40 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools.Models/.gitignore +src/Org.OpenAPITools.Models/Animal.cs +src/Org.OpenAPITools.Models/ApiResponse.cs +src/Org.OpenAPITools.Models/Cat.cs +src/Org.OpenAPITools.Models/Category.cs +src/Org.OpenAPITools.Models/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools.Models/Dog.cs +src/Org.OpenAPITools.Models/Order.cs +src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj +src/Org.OpenAPITools.Models/Pet.cs +src/Org.OpenAPITools.Models/Tag.cs +src/Org.OpenAPITools.Models/TestEnum.cs +src/Org.OpenAPITools.Models/TestNullable.cs +src/Org.OpenAPITools.Models/User.cs +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Dockerfile +src/Org.OpenAPITools/Filters/BasePathFilter.cs +src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Program.cs +src/Org.OpenAPITools/Properties/launchSettings.json +src/Org.OpenAPITools/Startup.cs +src/Org.OpenAPITools/appsettings.Development.json +src/Org.OpenAPITools/appsettings.json +src/Org.OpenAPITools/wwwroot/README.md +src/Org.OpenAPITools/wwwroot/index.html +src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0-project4Models/Org.OpenAPITools.sln new file mode 100644 index 00000000000..d229ac688de --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/Org.OpenAPITools.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Models", "src\Org.OpenAPITools.Models\Org.OpenAPITools.Models.csproj", "{B8D18F25-F379-4B87-ACCC-F8A17E0AED38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + {B8D18F25-F379-4B87-ACCC-F8A17E0AED38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8D18F25-F379-4B87-ACCC-F8A17E0AED38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8D18F25-F379-4B87-ACCC-F8A17E0AED38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8D18F25-F379-4B87-ACCC-F8A17E0AED38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/README.md b/samples/server/petstore/aspnetcore-8.0-project4Models/README.md new file mode 100644 index 00000000000..5da4721474e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/README.md @@ -0,0 +1,50 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` +## Run in Docker + +``` +cd src/Org.OpenAPITools +docker build -t org.openapitools . +docker run -p 5000:8080 org.openapitools +``` diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/build.bat b/samples/server/petstore/aspnetcore-8.0-project4Models/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/build.sh b/samples/server/petstore/aspnetcore-8.0-project4Models/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/.gitignore b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Animal.cs new file mode 100644 index 00000000000..4b04346e358 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Animal.cs @@ -0,0 +1,142 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using JsonSubTypes; +using Swashbuckle.AspNetCore.Annotations; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [SwaggerDiscriminator("ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [SwaggerSubType(typeof(Cat), DiscriminatorValue = "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + [SwaggerSubType(typeof(Dog), DiscriminatorValue = "DOG")] + public partial class Animal : IEquatable + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } = "red"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Animal)obj); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ClassName == other.ClassName || + ClassName != null && + ClassName.Equals(other.ClassName) + ) && + ( + Color == other.Color || + Color != null && + Color.Equals(other.Color) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (ClassName != null) + hashCode = hashCode * 59 + ClassName.GetHashCode(); + if (Color != null) + hashCode = hashCode * 59 + Color.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Animal left, Animal right) + { + return Equals(left, right); + } + + public static bool operator !=(Animal left, Animal right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/ApiResponse.cs new file mode 100644 index 00000000000..2358b07fa7d --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/ApiResponse.cs @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public partial class ApiResponse : IEquatable + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ApiResponse)obj); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + + Code.Equals(other.Code) + ) && + ( + Type == other.Type || + Type != null && + Type.Equals(other.Type) + ) && + ( + Message == other.Message || + Message != null && + Message.Equals(other.Message) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Code.GetHashCode(); + if (Type != null) + hashCode = hashCode * 59 + Type.GetHashCode(); + if (Message != null) + hashCode = hashCode * 59 + Message.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ApiResponse left, ApiResponse right) + { + return Equals(left, right); + } + + public static bool operator !=(ApiResponse left, ApiResponse right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Cat.cs new file mode 100644 index 00000000000..ef5b1be3efb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Cat.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal, IEquatable + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Cat)obj); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Declawed == other.Declawed || + + Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Declawed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Cat left, Cat right) + { + return Equals(left, right); + } + + public static bool operator !=(Cat left, Cat right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Category.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Category.cs new file mode 100644 index 00000000000..7898abbb9ff --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Category.cs @@ -0,0 +1,134 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public partial class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Category)obj); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Category left, Category right) + { + return Equals(left, right); + } + + public static bool operator !=(Category left, Category right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..7d1a4ed4ffb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonConvert.DeserializeObject(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Dog.cs new file mode 100644 index 00000000000..2dd6a7f4362 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Dog.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal, IEquatable + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Dog)obj); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Breed == other.Breed || + Breed != null && + Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Breed != null) + hashCode = hashCode * 59 + Breed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Dog left, Dog right) + { + return Equals(left, right); + } + + public static bool operator !=(Dog left, Dog right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Order.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Order.cs new file mode 100644 index 00000000000..5076e34732a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Order.cs @@ -0,0 +1,219 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public partial class Order : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool Complete { get; set; } = false; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Order)obj); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + PetId == other.PetId || + + PetId.Equals(other.PetId) + ) && + ( + Quantity == other.Quantity || + + Quantity.Equals(other.Quantity) + ) && + ( + ShipDate == other.ShipDate || + + ShipDate.Equals(other.ShipDate) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ) && + ( + Complete == other.Complete || + + Complete.Equals(other.Complete) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + + hashCode = hashCode * 59 + PetId.GetHashCode(); + + hashCode = hashCode * 59 + Quantity.GetHashCode(); + + hashCode = hashCode * 59 + ShipDate.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + + hashCode = hashCode * 59 + Complete.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Order left, Order right) + { + return Equals(left, right); + } + + public static bool operator !=(Order left, Order right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj new file mode 100644 index 00000000000..4ac779e720a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Org.OpenAPITools.Models.csproj @@ -0,0 +1,23 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Library + Org.OpenAPITools.Models + Org.OpenAPITools.Models + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Pet.cs new file mode 100644 index 00000000000..31a57ea7735 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Pet.cs @@ -0,0 +1,224 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public partial class Pet : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Pet)obj); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Category == other.Category || + Category != null && + Category.Equals(other.Category) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + PhotoUrls == other.PhotoUrls || + PhotoUrls != null && + other.PhotoUrls != null && + PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + Tags == other.Tags || + Tags != null && + other.Tags != null && + Tags.SequenceEqual(other.Tags) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Category != null) + hashCode = hashCode * 59 + Category.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (PhotoUrls != null) + hashCode = hashCode * 59 + PhotoUrls.GetHashCode(); + if (Tags != null) + hashCode = hashCode * 59 + Tags.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Pet left, Pet right) + { + return Equals(left, right); + } + + public static bool operator !=(Pet left, Pet right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Tag.cs new file mode 100644 index 00000000000..84ccb02359b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/Tag.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public partial class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Tag)obj); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Tag left, Tag right) + { + return Equals(left, right); + } + + public static bool operator !=(Tag left, Tag right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestEnum.cs new file mode 100644 index 00000000000..10227a2a2c4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestEnum.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestNullable.cs new file mode 100644 index 00000000000..8db75f2dafd --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/TestNullable.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class TestNullable : IEquatable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string NullableName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TestNullable {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" NullableName: ").Append(NullableName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((TestNullable)obj); + } + + /// + /// Returns true if TestNullable instances are equal + /// + /// Instance of TestNullable to be compared + /// Boolean + public bool Equals(TestNullable other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + NullableName == other.NullableName || + NullableName != null && + NullableName.Equals(other.NullableName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (NullableName != null) + hashCode = hashCode * 59 + NullableName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(TestNullable left, TestNullable right) + { + return Equals(left, right); + } + + public static bool operator !=(TestNullable left, TestNullable right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/User.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/User.cs new file mode 100644 index 00000000000..9155e7309fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools.Models/User.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public partial class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((User)obj); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Username == other.Username || + Username != null && + Username.Equals(other.Username) + ) && + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ) && + ( + Phone == other.Phone || + Phone != null && + Phone.Equals(other.Phone) + ) && + ( + UserStatus == other.UserStatus || + + UserStatus.Equals(other.UserStatus) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Username != null) + hashCode = hashCode * 59 + Username.GetHashCode(); + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + if (Phone != null) + hashCode = hashCode * 59 + Phone.GetHashCode(); + + hashCode = hashCode * 59 + UserStatus.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(User left, User right) + { + return Equals(left, right); + } + + public static bool operator !=(User left, User right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..315555e2a44 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..beabdde2fb1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + [SwaggerOperation("TestGet")] + public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..a0f2bd3b231 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeNullableExampleTest")] + [SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")] + public virtual IActionResult FakeNullableExampleTest() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(TestNullable)); + string exampleJson = null; + exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(TestNullable); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeParameterExampleTest")] + public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..7dded4e0f16 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,260 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("AddPet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult AddPet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + [SwaggerOperation("DeletePet")] + public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + throw new NotImplementedException(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + [Obsolete] + public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("UpdatePet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult UpdatePet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n doggie\n \n aeiou\n \n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + [SwaggerOperation("UpdatePetWithForm")] + public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status) + { + + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + + throw new NotImplementedException(); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [SwaggerOperation("UploadFile")] + [SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")] + public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(ApiResponse)); + string exampleJson = null; + exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(ApiResponse); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..b925426c761 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,141 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("DeleteOrder")] + public virtual IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(statusCode: 200, type: typeof(Dictionary), description: "successful operation")] + public virtual IActionResult GetInventory() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Dictionary)); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : new Dictionary(); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("PlaceOrder")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult PlaceOrder([FromBody]Order order) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..6d7094c81a9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUser")] + public virtual IActionResult CreateUser([FromBody]User user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithArrayInput")] + public virtual IActionResult CreateUsersWithArrayInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithListInput")] + public virtual IActionResult CreateUsersWithListInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("DeleteUser")] + public virtual IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")] + public virtual IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(User)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}"; + exampleJson = "\n 123456789\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n 123\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(User); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + [SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")] + public virtual IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(string)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(string); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("LogoutUser")] + public virtual IActionResult LogoutUser() + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("UpdateUser")] + public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Dockerfile new file mode 100644 index 00000000000..c24f45dbc5a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/BasePathFilter.cs new file mode 100644 index 00000000000..97ae99c9295 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 00000000000..9eccd5c317f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..ffc93a97da3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,27 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs new file mode 100644 index 00000000000..00ed16ed675 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Properties/launchSettings.json new file mode 100644 index 00000000000..99cfeea4b91 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "openapi", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OpenAPI": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "openapi", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/openapi", + "publishAllPorts": true, + "useSSL": true + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Startup.cs new file mode 100644 index 00000000000..0adda89acc0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,155 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter + { + NamingStrategy = new CamelCaseNamingStrategy() + }); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + services + .AddSwaggerGenNewtonsoftSupport(); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.Development.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.Development.json new file mode 100644 index 00000000000..e203e9407e7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.json new file mode 100644 index 00000000000..def9159a7d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/README.md b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/index.html b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/index.html new file mode 100644 index 00000000000..f3318bc90a1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/index.html @@ -0,0 +1 @@ + diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json new file mode 100644 index 00000000000..b47dce3d2c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0-useSwashBuckle/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/FILES new file mode 100644 index 00000000000..8da23f0cd09 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/FILES @@ -0,0 +1,28 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/Models/Animal.cs +src/Org.OpenAPITools/Models/ApiResponse.cs +src/Org.OpenAPITools/Models/Cat.cs +src/Org.OpenAPITools/Models/Category.cs +src/Org.OpenAPITools/Models/Dog.cs +src/Org.OpenAPITools/Models/Order.cs +src/Org.OpenAPITools/Models/Pet.cs +src/Org.OpenAPITools/Models/Tag.cs +src/Org.OpenAPITools/Models/TestEnum.cs +src/Org.OpenAPITools/Models/TestNullable.cs +src/Org.OpenAPITools/Models/User.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Org.OpenAPITools.nuspec diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/Org.OpenAPITools.sln new file mode 100644 index 00000000000..c2bc3876420 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/Org.OpenAPITools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/README.md b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/README.md new file mode 100644 index 00000000000..9a7702f6979 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/README.md @@ -0,0 +1,43 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.bat b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.sh b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..315555e2a44 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..7ef97038061 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,38 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public abstract class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + public abstract IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..d1cc02582f7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public abstract class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(TestNullable))] + public abstract IActionResult FakeNullableExampleTest(); + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + public abstract IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..20656c81638 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,136 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public abstract class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Pet))] + public abstract IActionResult AddPet([FromBody]Pet pet); + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + public abstract IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey); + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(List))] + public abstract IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status); + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(List))] + [Obsolete] + public abstract IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags); + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Pet))] + public abstract IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId); + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Pet))] + public abstract IActionResult UpdatePet([FromBody]Pet pet); + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + public abstract IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status); + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(ApiResponse))] + public abstract IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..3ec0d549c4a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,79 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public abstract class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + public abstract IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId); + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Dictionary))] + public abstract IActionResult GetInventory(); + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Order))] + public abstract IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId); + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(Order))] + public abstract IActionResult PlaceOrder([FromBody]Order order); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..2de74542f79 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,129 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public abstract class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + public abstract IActionResult CreateUser([FromBody]User user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + public abstract IActionResult CreateUsersWithArrayInput([FromBody]List user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + public abstract IActionResult CreateUsersWithListInput([FromBody]List user); + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + public abstract IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username); + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(User))] + public abstract IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username); + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [ProducesResponseType(statusCode: 200, type: typeof(string))] + public abstract IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password); + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + public abstract IActionResult LogoutUser(); + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + public abstract IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..7d1a4ed4ffb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonConvert.DeserializeObject(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Animal.cs new file mode 100644 index 00000000000..9dcb10746c9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Animal.cs @@ -0,0 +1,138 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using JsonSubTypes; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + public class Animal : IEquatable + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } = "red"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Animal)obj); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ClassName == other.ClassName || + ClassName != null && + ClassName.Equals(other.ClassName) + ) && + ( + Color == other.Color || + Color != null && + Color.Equals(other.Color) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (ClassName != null) + hashCode = hashCode * 59 + ClassName.GetHashCode(); + if (Color != null) + hashCode = hashCode * 59 + Color.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Animal left, Animal right) + { + return Equals(left, right); + } + + public static bool operator !=(Animal left, Animal right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/ApiResponse.cs new file mode 100644 index 00000000000..4963d2e9b8e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/ApiResponse.cs @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public class ApiResponse : IEquatable + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ApiResponse)obj); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + + Code.Equals(other.Code) + ) && + ( + Type == other.Type || + Type != null && + Type.Equals(other.Type) + ) && + ( + Message == other.Message || + Message != null && + Message.Equals(other.Message) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Code.GetHashCode(); + if (Type != null) + hashCode = hashCode * 59 + Type.GetHashCode(); + if (Message != null) + hashCode = hashCode * 59 + Message.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ApiResponse left, ApiResponse right) + { + return Equals(left, right); + } + + public static bool operator !=(ApiResponse left, ApiResponse right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Cat.cs new file mode 100644 index 00000000000..916049da141 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Cat.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public class Cat : Animal, IEquatable + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Cat)obj); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Declawed == other.Declawed || + + Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Declawed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Cat left, Cat right) + { + return Equals(left, right); + } + + public static bool operator !=(Cat left, Cat right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Category.cs new file mode 100644 index 00000000000..67a508071a7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Category.cs @@ -0,0 +1,134 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Category)obj); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Category left, Category right) + { + return Equals(left, right); + } + + public static bool operator !=(Category left, Category right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Dog.cs new file mode 100644 index 00000000000..22dae6cd3d7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Dog.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public class Dog : Animal, IEquatable + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Dog)obj); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Breed == other.Breed || + Breed != null && + Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Breed != null) + hashCode = hashCode * 59 + Breed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Dog left, Dog right) + { + return Equals(left, right); + } + + public static bool operator !=(Dog left, Dog right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Order.cs new file mode 100644 index 00000000000..5b3d6c1aaac --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Order.cs @@ -0,0 +1,219 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public class Order : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool Complete { get; set; } = false; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Order)obj); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + PetId == other.PetId || + + PetId.Equals(other.PetId) + ) && + ( + Quantity == other.Quantity || + + Quantity.Equals(other.Quantity) + ) && + ( + ShipDate == other.ShipDate || + + ShipDate.Equals(other.ShipDate) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ) && + ( + Complete == other.Complete || + + Complete.Equals(other.Complete) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + + hashCode = hashCode * 59 + PetId.GetHashCode(); + + hashCode = hashCode * 59 + Quantity.GetHashCode(); + + hashCode = hashCode * 59 + ShipDate.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + + hashCode = hashCode * 59 + Complete.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Order left, Order right) + { + return Equals(left, right); + } + + public static bool operator !=(Order left, Order right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Pet.cs new file mode 100644 index 00000000000..0b638a66b14 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Pet.cs @@ -0,0 +1,224 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public class Pet : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Pet)obj); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Category == other.Category || + Category != null && + Category.Equals(other.Category) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + PhotoUrls == other.PhotoUrls || + PhotoUrls != null && + other.PhotoUrls != null && + PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + Tags == other.Tags || + Tags != null && + other.Tags != null && + Tags.SequenceEqual(other.Tags) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Category != null) + hashCode = hashCode * 59 + Category.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (PhotoUrls != null) + hashCode = hashCode * 59 + PhotoUrls.GetHashCode(); + if (Tags != null) + hashCode = hashCode * 59 + Tags.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Pet left, Pet right) + { + return Equals(left, right); + } + + public static bool operator !=(Pet left, Pet right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Tag.cs new file mode 100644 index 00000000000..a9e492ebddf --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/Tag.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Tag)obj); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Tag left, Tag right) + { + return Equals(left, right); + } + + public static bool operator !=(Tag left, Tag right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestEnum.cs new file mode 100644 index 00000000000..10227a2a2c4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestEnum.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestNullable.cs new file mode 100644 index 00000000000..d61290a27c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/TestNullable.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public class TestNullable : IEquatable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string NullableName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TestNullable {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" NullableName: ").Append(NullableName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((TestNullable)obj); + } + + /// + /// Returns true if TestNullable instances are equal + /// + /// Instance of TestNullable to be compared + /// Boolean + public bool Equals(TestNullable other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + NullableName == other.NullableName || + NullableName != null && + NullableName.Equals(other.NullableName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (NullableName != null) + hashCode = hashCode * 59 + NullableName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(TestNullable left, TestNullable right) + { + return Equals(left, right); + } + + public static bool operator !=(TestNullable left, TestNullable right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/User.cs new file mode 100644 index 00000000000..ab41cb3843a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Models/User.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((User)obj); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Username == other.Username || + Username != null && + Username.Equals(other.Username) + ) && + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ) && + ( + Phone == other.Phone || + Phone != null && + Phone.Equals(other.Phone) + ) && + ( + UserStatus == other.UserStatus || + + UserStatus.Equals(other.UserStatus) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Username != null) + hashCode = hashCode * 59 + Username.GetHashCode(); + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + if (Phone != null) + hashCode = hashCode * 59 + Phone.GetHashCode(); + + hashCode = hashCode * 59 + UserStatus.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(User left, User right) + { + return Equals(left, right); + } + + public static bool operator !=(User left, User right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..9fa884cf930 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,26 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Library + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec new file mode 100644 index 00000000000..b1d83a35961 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec @@ -0,0 +1,20 @@ + + + + $id$ + 1.0.0 + OpenAPI Library + OpenAPI + OpenAPI + https://www.apache.org/licenses/LICENSE-2.0.html + + false + A library generated from a OpenAPI doc + Summary of changes made in this release of the package. + No Copyright + Org.OpenAPITools + + diff --git a/samples/server/petstore/aspnetcore-8.0/.openapi-generator-ignore b/samples/server/petstore/aspnetcore-8.0/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# 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 OpenAPI Generator 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/aspnetcore-8.0/.openapi-generator/FILES b/samples/server/petstore/aspnetcore-8.0/.openapi-generator/FILES new file mode 100644 index 00000000000..5813de3b53b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/.openapi-generator/FILES @@ -0,0 +1,38 @@ +Org.OpenAPITools.sln +README.md +build.bat +build.sh +src/Org.OpenAPITools/.gitignore +src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs +src/Org.OpenAPITools/Authentication/ApiAuthentication.cs +src/Org.OpenAPITools/Controllers/DefaultApi.cs +src/Org.OpenAPITools/Controllers/FakeApi.cs +src/Org.OpenAPITools/Controllers/PetApi.cs +src/Org.OpenAPITools/Controllers/StoreApi.cs +src/Org.OpenAPITools/Controllers/UserApi.cs +src/Org.OpenAPITools/Converters/CustomEnumConverter.cs +src/Org.OpenAPITools/Dockerfile +src/Org.OpenAPITools/Filters/BasePathFilter.cs +src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +src/Org.OpenAPITools/Models/Animal.cs +src/Org.OpenAPITools/Models/ApiResponse.cs +src/Org.OpenAPITools/Models/Cat.cs +src/Org.OpenAPITools/Models/Category.cs +src/Org.OpenAPITools/Models/Dog.cs +src/Org.OpenAPITools/Models/Order.cs +src/Org.OpenAPITools/Models/Pet.cs +src/Org.OpenAPITools/Models/Tag.cs +src/Org.OpenAPITools/Models/TestEnum.cs +src/Org.OpenAPITools/Models/TestNullable.cs +src/Org.OpenAPITools/Models/User.cs +src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/Program.cs +src/Org.OpenAPITools/Properties/launchSettings.json +src/Org.OpenAPITools/Startup.cs +src/Org.OpenAPITools/appsettings.Development.json +src/Org.OpenAPITools/appsettings.json +src/Org.OpenAPITools/wwwroot/README.md +src/Org.OpenAPITools/wwwroot/index.html +src/Org.OpenAPITools/wwwroot/openapi-original.json diff --git a/samples/server/petstore/aspnetcore-8.0/.openapi-generator/VERSION b/samples/server/petstore/aspnetcore-8.0/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/petstore/aspnetcore-8.0/Org.OpenAPITools.sln b/samples/server/petstore/aspnetcore-8.0/Org.OpenAPITools.sln new file mode 100644 index 00000000000..c2bc3876420 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/Org.OpenAPITools.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/server/petstore/aspnetcore-8.0/README.md b/samples/server/petstore/aspnetcore-8.0/README.md new file mode 100644 index 00000000000..5da4721474e --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/README.md @@ -0,0 +1,50 @@ +# Org.OpenAPITools - ASP.NET Core 8.0 Server + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Upgrade NuGet Packages + +NuGet packages get frequently updated. + +To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool. + + +Install dotnet-outdated tool: + +``` +dotnet tool install --global dotnet-outdated-tool +``` + +Upgrade only to new minor versions of packages + +``` +dotnet outdated --upgrade --version-lock Major +``` + +Upgrade to all new versions of packages (more likely to include breaking API changes) + +``` +dotnet outdated --upgrade +``` + + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` +## Run in Docker + +``` +cd src/Org.OpenAPITools +docker build -t org.openapitools . +docker run -p 5000:8080 org.openapitools +``` diff --git a/samples/server/petstore/aspnetcore-8.0/build.bat b/samples/server/petstore/aspnetcore-8.0/build.bat new file mode 100644 index 00000000000..cd65518e428 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://openapi-generator.tech +:: + +@echo off + +dotnet restore src\Org.OpenAPITools +dotnet build src\Org.OpenAPITools +echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web. +echo. diff --git a/samples/server/petstore/aspnetcore-8.0/build.sh b/samples/server/petstore/aspnetcore-8.0/build.sh new file mode 100644 index 00000000000..afbeddb8378 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://openapi-generator.tech +# + +dotnet restore src/Org.OpenAPITools/ && \ + dotnet build src/Org.OpenAPITools/ && \ + echo "Now, run the following to start the project: dotnet run -p src/Org.OpenAPITools/Org.OpenAPITools.csproj --launch-profile web" diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/.gitignore b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/.gitignore new file mode 100644 index 00000000000..1ee53850b84 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/.gitignore @@ -0,0 +1,362 @@ +## 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/aspnetcore-8.0/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 00000000000..315555e2a44 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Org.OpenAPITools.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + if (context.ActionDescriptor is ControllerActionDescriptor descriptor) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + if (attributeInstance is ValidationAttribute validationAttribute) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs new file mode 100644 index 00000000000..bfbe6290f23 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Authentication/ApiAuthentication.cs @@ -0,0 +1,72 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Org.OpenAPITools.Authentication +{ + /// + /// A requirement that an ApiKey must be present. + /// + public class ApiKeyRequirement : IAuthorizationRequirement + { + /// + /// Get the list of api keys + /// + public IReadOnlyList ApiKeys { get; } + + /// + /// Get the policy name, + /// + public string PolicyName { get; } + + /// + /// Create a new instance of the class. + /// + /// + /// + public ApiKeyRequirement(IEnumerable apiKeys, string policyName) + { + ApiKeys = apiKeys?.ToList() ?? new List(); + PolicyName = policyName; + } + } + + /// + /// Enforce that an api key is present. + /// + public class ApiKeyRequirementHandler : AuthorizationHandler + { + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + SucceedRequirementIfApiKeyPresentAndValid(context, requirement); + return Task.CompletedTask; + } + + private void SucceedRequirementIfApiKeyPresentAndValid(AuthorizationHandlerContext context, ApiKeyRequirement requirement) + { + + if (context.Resource is AuthorizationFilterContext authorizationFilterContext) + { + var apiKey = authorizationFilterContext.HttpContext.Request.Headers["api_key"].FirstOrDefault(); + if (requirement.PolicyName == "api_key" && apiKey != null && requirement.ApiKeys.Any(requiredApiKey => apiKey == requiredApiKey)) + { + context.Succeed(requirement); + } + } + + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/DefaultApi.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/DefaultApi.cs new file mode 100644 index 00000000000..beabdde2fb1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/DefaultApi.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class DefaultApiController : ControllerBase + { + /// + /// Test API + /// + /// + /// OK + [HttpGet] + [Route("/v2/test")] + [ValidateModelState] + [SwaggerOperation("TestGet")] + public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/FakeApi.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/FakeApi.cs new file mode 100644 index 00000000000..a0f2bd3b231 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/FakeApi.cs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class FakeApiController : ControllerBase + { + /// + /// Fake endpoint to test nullable example (object) + /// + /// Successful operation + [HttpGet] + [Route("/v2/fake/nullable_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeNullableExampleTest")] + [SwaggerResponse(statusCode: 200, type: typeof(TestNullable), description: "Successful operation")] + public virtual IActionResult FakeNullableExampleTest() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(TestNullable)); + string exampleJson = null; + exampleJson = "{\n \"nullableName\" : \"nullableName\",\n \"name\" : \"name\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(TestNullable); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// fake endpoint to test parameter example (object) + /// + /// + /// successful operation + [HttpGet] + [Route("/v2/fake/parameter_example_test")] + [ValidateModelState] + [SwaggerOperation("FakeParameterExampleTest")] + public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/PetApi.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/PetApi.cs new file mode 100644 index 00000000000..7dded4e0f16 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/PetApi.cs @@ -0,0 +1,260 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class PetApiController : ControllerBase + { + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid input + [HttpPost] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("AddPet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult AddPet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/v2/pet/{petId}")] + [ValidateModelState] + [SwaggerOperation("DeletePet")] + public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + throw new NotImplementedException(); + } + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + /// Status values that need to be considered for filter (deprecated) + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/v2/pet/findByStatus")] + [ValidateModelState] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List status) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/v2/pet/findByTags")] + [ValidateModelState] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "successful operation")] + [Obsolete] + public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List tags) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(List)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find pet by ID + /// + /// Returns a single pet + /// ID of pet to return + /// successful operation + /// Invalid ID supplied + /// Pet not found + [HttpGet] + [Route("/v2/pet/{petId}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetPetById")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n \n 123456789\n aeiou\n \n doggie\n \n aeiou\n \n \n \n 123456789\n aeiou\n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// successful operation + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/v2/pet")] + [Consumes("application/json", "application/xml")] + [ValidateModelState] + [SwaggerOperation("UpdatePet")] + [SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")] + public virtual IActionResult UpdatePet([FromBody]Pet pet) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Pet)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + string exampleJson = null; + exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}"; + exampleJson = "\n 123456789\n doggie\n \n aeiou\n \n \n \n aeiou\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Pet); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/v2/pet/{petId}")] + [Consumes("application/x-www-form-urlencoded")] + [ValidateModelState] + [SwaggerOperation("UpdatePetWithForm")] + public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status) + { + + //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(405); + + throw new NotImplementedException(); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/v2/pet/{petId}/uploadImage")] + [Consumes("multipart/form-data")] + [ValidateModelState] + [SwaggerOperation("UploadFile")] + [SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")] + public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(ApiResponse)); + string exampleJson = null; + exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(ApiResponse); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/StoreApi.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/StoreApi.cs new file mode 100644 index 00000000000..b925426c761 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/StoreApi.cs @@ -0,0 +1,141 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class StoreApiController : ControllerBase + { + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("DeleteOrder")] + public virtual IActionResult DeleteOrder([FromRoute (Name = "orderId")][Required]string orderId) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/v2/store/inventory")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(statusCode: 200, type: typeof(Dictionary), description: "successful operation")] + public virtual IActionResult GetInventory() + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Dictionary)); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : new Dictionary(); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [HttpGet] + [Route("/v2/store/order/{orderId}")] + [ValidateModelState] + [SwaggerOperation("GetOrderById")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult GetOrderById([FromRoute (Name = "orderId")][Required][Range(1, 5)]long orderId) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [HttpPost] + [Route("/v2/store/order")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("PlaceOrder")] + [SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")] + public virtual IActionResult PlaceOrder([FromBody]Order order) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(Order)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}"; + exampleJson = "\n 123456789\n 123456789\n 123\n 2000-01-23T04:56:07.000Z\n aeiou\n true\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(Order); + //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/UserApi.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/UserApi.cs new file mode 100644 index 00000000000..6d7094c81a9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Controllers/UserApi.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using Org.OpenAPITools.Attributes; +using Org.OpenAPITools.Models; + +namespace Org.OpenAPITools.Controllers +{ + /// + /// + /// + [ApiController] + public class UserApiController : ControllerBase + { + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/v2/user")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUser")] + public virtual IActionResult CreateUser([FromBody]User user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithArray")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithArrayInput")] + public virtual IActionResult CreateUsersWithArrayInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/v2/user/createWithList")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("CreateUsersWithListInput")] + public virtual IActionResult CreateUsersWithListInput([FromBody]List user) + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("DeleteUser")] + public virtual IActionResult DeleteUser([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [HttpGet] + [Route("/v2/user/{username}")] + [ValidateModelState] + [SwaggerOperation("GetUserByName")] + [SwaggerResponse(statusCode: 200, type: typeof(User), description: "successful operation")] + public virtual IActionResult GetUserByName([FromRoute (Name = "username")][Required]string username) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(User)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + string exampleJson = null; + exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}"; + exampleJson = "\n 123456789\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n aeiou\n 123\n"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(User); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [HttpGet] + [Route("/v2/user/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + [SwaggerResponse(statusCode: 200, type: typeof(string), description: "successful operation")] + public virtual IActionResult LoginUser([FromQuery (Name = "username")][Required()][RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]string username, [FromQuery (Name = "password")][Required()]string password) + { + + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200, default(string)); + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(string); + //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Logs out current logged in user session + /// + /// successful operation + [HttpGet] + [Route("/v2/user/logout")] + [Authorize(Policy = "api_key")] + [ValidateModelState] + [SwaggerOperation("LogoutUser")] + public virtual IActionResult LogoutUser() + { + + //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(0); + + throw new NotImplementedException(); + } + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/v2/user/{username}")] + [Authorize(Policy = "api_key")] + [Consumes("application/json")] + [ValidateModelState] + [SwaggerOperation("UpdateUser")] + public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user) + { + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(404); + + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs new file mode 100644 index 00000000000..7d1a4ed4ffb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Converters/CustomEnumConverter.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.ComponentModel; +using System.Globalization; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Converters +{ + /// + /// Custom string to enum converter + /// + public class CustomEnumConverter : TypeConverter + { + /// + /// Determine if we can convert a type to an enum + /// + /// + /// + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + /// + /// Convert from a type value to an enum + /// + /// + /// + /// + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var s = value as string; + if (string.IsNullOrEmpty(s)) + { + return null; + } + + return JsonConvert.DeserializeObject(@"""" + value + @""""); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Dockerfile new file mode 100644 index 00000000000..c24f45dbc5a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs new file mode 100644 index 00000000000..97ae99c9295 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 00000000000..9eccd5c317f --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs new file mode 100644 index 00000000000..18796da30fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Animal.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Animal.cs new file mode 100644 index 00000000000..4b04346e358 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Animal.cs @@ -0,0 +1,142 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using JsonSubTypes; +using Swashbuckle.AspNetCore.Annotations; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + [JsonConverter(typeof(JsonSubtypes), "ClassName")] + [SwaggerDiscriminator("ClassName")] + [JsonSubtypes.KnownSubType(typeof(Cat), "CAT")] + [SwaggerSubType(typeof(Cat), DiscriminatorValue = "CAT")] + [JsonSubtypes.KnownSubType(typeof(Dog), "DOG")] + [SwaggerSubType(typeof(Dog), DiscriminatorValue = "DOG")] + public partial class Animal : IEquatable + { + /// + /// Gets or Sets ClassName + /// + [Required] + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Color + /// + [DataMember(Name="color", EmitDefaultValue=false)] + public string Color { get; set; } = "red"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Animal)obj); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ClassName == other.ClassName || + ClassName != null && + ClassName.Equals(other.ClassName) + ) && + ( + Color == other.Color || + Color != null && + Color.Equals(other.Color) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (ClassName != null) + hashCode = hashCode * 59 + ClassName.GetHashCode(); + if (Color != null) + hashCode = hashCode * 59 + Color.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Animal left, Animal right) + { + return Equals(left, right); + } + + public static bool operator !=(Animal left, Animal right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/ApiResponse.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/ApiResponse.cs new file mode 100644 index 00000000000..2358b07fa7d --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/ApiResponse.cs @@ -0,0 +1,147 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Describes the result of uploading an image resource + /// + [DataContract] + public partial class ApiResponse : IEquatable + { + /// + /// Gets or Sets Code + /// + [DataMember(Name="code", EmitDefaultValue=true)] + public int Code { get; set; } + + /// + /// Gets or Sets Type + /// + [DataMember(Name="type", EmitDefaultValue=false)] + public string Type { get; set; } + + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + public string Message { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ApiResponse)obj); + } + + /// + /// Returns true if ApiResponse instances are equal + /// + /// Instance of ApiResponse to be compared + /// Boolean + public bool Equals(ApiResponse other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + + Code.Equals(other.Code) + ) && + ( + Type == other.Type || + Type != null && + Type.Equals(other.Type) + ) && + ( + Message == other.Message || + Message != null && + Message.Equals(other.Message) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Code.GetHashCode(); + if (Type != null) + hashCode = hashCode * 59 + Type.GetHashCode(); + if (Message != null) + hashCode = hashCode * 59 + Message.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ApiResponse left, ApiResponse right) + { + return Equals(left, right); + } + + public static bool operator !=(ApiResponse left, ApiResponse right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Cat.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Cat.cs new file mode 100644 index 00000000000..ef5b1be3efb --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Cat.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal, IEquatable + { + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=true)] + public bool Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Cat)obj); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Declawed == other.Declawed || + + Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Declawed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Cat left, Cat right) + { + return Equals(left, right); + } + + public static bool operator !=(Cat left, Cat right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Category.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Category.cs new file mode 100644 index 00000000000..7898abbb9ff --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Category.cs @@ -0,0 +1,134 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A category for a pet + /// + [DataContract] + public partial class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Category)obj); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Category left, Category right) + { + return Equals(left, right); + } + + public static bool operator !=(Category left, Category right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Dog.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Dog.cs new file mode 100644 index 00000000000..2dd6a7f4362 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Dog.cs @@ -0,0 +1,119 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal, IEquatable + { + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Dog)obj); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Breed == other.Breed || + Breed != null && + Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Breed != null) + hashCode = hashCode * 59 + Breed.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Dog left, Dog right) + { + return Equals(left, right); + } + + public static bool operator !=(Dog left, Dog right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Order.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Order.cs new file mode 100644 index 00000000000..5076e34732a --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Order.cs @@ -0,0 +1,219 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// An order for a pets from the pet store + /// + [DataContract] + public partial class Order : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=true)] + public long PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=true)] + public int Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=true)] + public DateTime ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum PlacedEnum for placed + /// + [EnumMember(Value = "placed")] + PlacedEnum = 1, + + /// + /// Enum ApprovedEnum for approved + /// + [EnumMember(Value = "approved")] + ApprovedEnum = 2, + + /// + /// Enum DeliveredEnum for delivered + /// + [EnumMember(Value = "delivered")] + DeliveredEnum = 3 + } + + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=true)] + public bool Complete { get; set; } = false; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Order)obj); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + PetId == other.PetId || + + PetId.Equals(other.PetId) + ) && + ( + Quantity == other.Quantity || + + Quantity.Equals(other.Quantity) + ) && + ( + ShipDate == other.ShipDate || + + ShipDate.Equals(other.ShipDate) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ) && + ( + Complete == other.Complete || + + Complete.Equals(other.Complete) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + + hashCode = hashCode * 59 + PetId.GetHashCode(); + + hashCode = hashCode * 59 + Quantity.GetHashCode(); + + hashCode = hashCode * 59 + ShipDate.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + + hashCode = hashCode * 59 + Complete.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Order left, Order right) + { + return Equals(left, right); + } + + public static bool operator !=(Order left, Order right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Pet.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Pet.cs new file mode 100644 index 00000000000..31a57ea7735 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Pet.cs @@ -0,0 +1,224 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A pet for sale in the pet store + /// + [DataContract] + public partial class Pet : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + /// doggie + [Required] + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [Required] + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum AvailableEnum for available + /// + [EnumMember(Value = "available")] + AvailableEnum = 1, + + /// + /// Enum PendingEnum for pending + /// + [EnumMember(Value = "pending")] + PendingEnum = 2, + + /// + /// Enum SoldEnum for sold + /// + [EnumMember(Value = "sold")] + SoldEnum = 3 + } + + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=true)] + public StatusEnum Status { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Pet)obj); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Category == other.Category || + Category != null && + Category.Equals(other.Category) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + PhotoUrls == other.PhotoUrls || + PhotoUrls != null && + other.PhotoUrls != null && + PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + Tags == other.Tags || + Tags != null && + other.Tags != null && + Tags.SequenceEqual(other.Tags) + ) && + ( + Status == other.Status || + + Status.Equals(other.Status) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Category != null) + hashCode = hashCode * 59 + Category.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (PhotoUrls != null) + hashCode = hashCode * 59 + PhotoUrls.GetHashCode(); + if (Tags != null) + hashCode = hashCode * 59 + Tags.GetHashCode(); + + hashCode = hashCode * 59 + Status.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Pet left, Pet right) + { + return Equals(left, right); + } + + public static bool operator !=(Pet left, Pet right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Tag.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Tag.cs new file mode 100644 index 00000000000..84ccb02359b --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/Tag.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A tag for a pet + /// + [DataContract] + public partial class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((Tag)obj); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Tag left, Tag right) + { + return Equals(left, right); + } + + public static bool operator !=(Tag left, Tag right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestEnum.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestEnum.cs new file mode 100644 index 00000000000..10227a2a2c4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestEnum.cs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// Gets or Sets TestEnum + /// + [TypeConverter(typeof(CustomEnumConverter))] + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum TestEnum + { + + /// + /// Enum AEnum for A + /// + [EnumMember(Value = "A")] + AEnum = 1, + + /// + /// Enum BEnum for B + /// + [EnumMember(Value = "B")] + BEnum = 2 + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestNullable.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestNullable.cs new file mode 100644 index 00000000000..8db75f2dafd --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/TestNullable.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// + /// + [DataContract] + public partial class TestNullable : IEquatable + { + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets NullableName + /// + [DataMember(Name="nullableName", EmitDefaultValue=true)] + public string NullableName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class TestNullable {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" NullableName: ").Append(NullableName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((TestNullable)obj); + } + + /// + /// Returns true if TestNullable instances are equal + /// + /// Instance of TestNullable to be compared + /// Boolean + public bool Equals(TestNullable other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + NullableName == other.NullableName || + NullableName != null && + NullableName.Equals(other.NullableName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (NullableName != null) + hashCode = hashCode * 59 + NullableName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(TestNullable left, TestNullable right) + { + return Equals(left, right); + } + + public static bool operator !=(TestNullable left, TestNullable right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/User.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/User.cs new file mode 100644 index 00000000000..9155e7309fc --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Models/User.cs @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Org.OpenAPITools.Converters; + +namespace Org.OpenAPITools.Models +{ + /// + /// A User who is purchasing from the pet store + /// + [DataContract] + public partial class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=true)] + public long Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=true)] + public int UserStatus { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((User)obj); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Id == other.Id || + + Id.Equals(other.Id) + ) && + ( + Username == other.Username || + Username != null && + Username.Equals(other.Username) + ) && + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ) && + ( + Phone == other.Phone || + Phone != null && + Phone.Equals(other.Phone) + ) && + ( + UserStatus == other.UserStatus || + + UserStatus.Equals(other.UserStatus) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + + hashCode = hashCode * 59 + Id.GetHashCode(); + if (Username != null) + hashCode = hashCode * 59 + Username.GetHashCode(); + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + if (Phone != null) + hashCode = hashCode * 59 + Phone.GetHashCode(); + + hashCode = hashCode * 59 + UserStatus.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(User left, User right) + { + return Equals(left, right); + } + + public static bool operator !=(User left, User right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs new file mode 100644 index 00000000000..122f58cabe4 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 00000000000..745c764b501 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,27 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs new file mode 100644 index 00000000000..00ed16ed675 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Properties/launchSettings.json new file mode 100644 index 00000000000..99cfeea4b91 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "openapi", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OpenAPI": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "openapi", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/openapi", + "publishAllPorts": true, + "useSSL": true + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Startup.cs new file mode 100644 index 00000000000..0adda89acc0 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,155 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter + { + NamingStrategy = new CamelCaseNamingStrategy() + }); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + services + .AddSwaggerGenNewtonsoftSupport(); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.Development.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.Development.json new file mode 100644 index 00000000000..e203e9407e7 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json new file mode 100644 index 00000000000..def9159a7d9 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/README.md b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/index.html b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/index.html new file mode 100644 index 00000000000..f3318bc90a1 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/index.html @@ -0,0 +1 @@ + diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/openapi-original.json new file mode 100644 index 00000000000..b47dce3d2c6 --- /dev/null +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 44fe2b0a0a2..5f7750b96b9 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -12,8 +12,8 @@ - - + +